How to create pseudo x-axis (or y-axis) tick labels?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm writing a program that requires me to change the x or y values by a factor in order to address a bug within Matlab. For example, if my current x-axis values are [0:10:100] and I have to divide the current x values by 33.3 so that the actual x-axis values in the plot will be [0:0.3:3], how do I set the x-axis tick labels, so that my users would still see the original [0:10:100] values as the x tick label?
What is the function to come up with the default x-axis tick values?
Many thanks!
3 commentaires
Réponse acceptée
dpb
le 16 Oct 2019
With the background as to "why", basic idea would be something like
Ratio=100/3; % the divisor for modifying the actual plotted values
hL=plot(x,y); % plot original data to get default axis pretty labels.
hAx=gca; % get the axes handle
xtk=xticks; % retrieve the tick values
delete(hL); hL=plot(x/Ratio,y); % remove original line; replace with scaled x values
hAx.XTicks=xticks/Ratio; % set ticks at original scaled values
hAx.XTickLabel=xticks; % write the labels to match the original unscaled values
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!