Changing step size of a graph
15 ビュー (過去 30 日間)
古いコメントを表示
I'm currently making a function that creates a graph for a given set of x and y data and I need to scale my X axis so that the step values are by 5 instead of the 10 that it creates automatically. How would I go about doing that? My current code is below.
file = load('SampleXYData.mat');
xData = file.xData;
yData = file.yData;
myFig = gcf;
myAx = axes(myFig);
myPlot = scatter(myAx, xData, yData);
myPlot.Marker = 'x';
myAx.Title.String = 'Scatter Plot';
myAx.YAxis.Label.String = 'Y';
myAx.XAxis.Label.String = 'X';
myAx.Box = 'on';
endAt = length(myAx.XAxis.TickLabels);
for i = 1:endAt
cVal = str2double(myAx.XAxis.TickLabels{i});
if mod(cVal , 10) == 0
myAx.XAxis.TickLabels{i} = ['\bf', myAx.XAxis.TickLabels{i}];
end
end
3 件のコメント
DGM
2021 年 3 月 22 日
Assuming we want the same extreme values:
myAx.XTick=myAx.XTick(1):5:myAx.XTick(end);
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Specifying Target for Graphics Output についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!