Why are Plot ticks increments inconsistently assigned?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
When I create a simple x-y plot, I would expect that the ticks woiuld increase in size as the samples in my data would increase. And that seems to be mostly the case. If I do a plot([0,1], [0, 1.8]), then my y-axis has ticks spaced 0.2 apart. If I do a plot([0,1], [0, 2.1]), then my y-axis has ticks spaced 0.5 apart. However, the max value is between 1.4 and 1.5, the tick spacing is 0.5 instead of 0.2, so there are not many ticks shown on the plot. I created a script to show how the tick increment is inconsistent.
Is this a bug, or is there some reason for this?
lim = logspace(log10(1), log10(10), 200)';
tick = zeros(length(lim), 1);
for n=1:length(lim)
p=plot([0,1], [0, lim(n)]); % create a simple plot with two points
tick(n) = p.Parent.YTick(2); % save the tick size
end
p=loglog(lim, tick);
xlabel('Max plot line value');
ylabel('Tick increment');
grid on
p.Parent.XTick = [1;1.4;1.5;2;5;10];
p.Parent.XTickLabel = arrayfun(@num2str, p.Parent.XTick, 'UniformOutput', false);
p.Parent.YTick = [0.1;0.2;0.5;1];
p.Parent.YTickLabel = arrayfun(@num2str, p.Parent.YTick, 'UniformOutput', false);
0 Commenti
Risposte (1)
Sanjana
il 8 Giu 2023
Hi Glenn,
As per the official documentation, there is no default spacing for ticks, but you can specify the spacing as per requirement using “xticks” and “yticks” properties of “Axes” in MATLAB.
These properties allow you to explicitly declare the location of the ticks along the respective axis.
Please refer to the following links, for further information,
Hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Axis Labels in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!