Effacer les filtres
Effacer les filtres

How do I change the values ​​of the axes?

2 vues (au cours des 30 derniers jours)
HelpAStudent
HelpAStudent le 11 Oct 2021
Hi I have this plot:
figure; errorbar(y,e,'-o')
legend('Cist -9dB', 'Cist -6dB', 'Cist -3dB', 'Cist 3dB', 'Cist 6dB', 'Cist 9dB');
xlabel('Gain');
ylabel('Grey Levels');
title('Dynamic range of 20dB');
The x axis start from 0 to 21, because I have 21 one point, how can I make the axis start from -20dB to 20dB (every 2 dB, To correspond to the first point -20dB, to the second -18 and so on: at each point increase of 2 dB up to +20)

Réponse acceptée

Star Strider
Star Strider le 11 Oct 2021
Try something like this —
x = linspace(0, 21, 25);
y = rand(size(x));
figure
plot(x, y)
xt = get(gca, 'XTick');
xtv = linspace(min(xt), max(xt), 21);
set(gca, 'XTick',xtv, 'XTickLabel',compose('%3d dB',-20:2:20))
Make appropriate changes to get the result you want.
.

Plus de réponses (0)

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by