Customizing scale of x-axis

17 vues (au cours des 30 derniers jours)
Bruno Rodrigues
Bruno Rodrigues le 2 Juin 2021
Modifié(e) : Adam Danz le 2 Juin 2021
Hello there,
I want to make a graph comparing my brother's hearing loss progress between the years. So far, so good.
However, audiograms generally have custom x-axis spacing between their values (they double for each interval). The spacing between 250 and 500 is the same as 500 to 1000, which is the same as 1000 to 2000, and so on, like the image shown below. How can I make this?
Thanks in advance.

Réponse acceptée

Adam Danz
Adam Danz le 2 Juin 2021
Modifié(e) : Adam Danz le 2 Juin 2021
Set the XScale to log and then specify the x-ticks.
Demo:
x = [250 500 1000 1500 3000 4000 6000 8000];
y = rand(size(x));
ax = gca();
plot(ax, x,y,'--ok')
xticks = [250 500 1000 2000 4000 8000];
set(ax, 'XScale','log','XLim',[250,10000],...
'XTick',xticks,'XMinorTick','off')
grid(ax,'on')
ax.MinorGridLineStyle = 'none';
  1 commentaire
Bruno Rodrigues
Bruno Rodrigues le 2 Juin 2021
This worked like a charm! Thank you! :)

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by