Yasmin
Yasmin

Reputation: 951

Specifc values over Axis in matlab

I want to plot 3D graph where Y-axis has only values 9, 99 , 999. I tried to use

Y= [9, 99 , 999];
set(gca,'YTickLabel',Y);
set(gca,'YTick',Y);

I want to have 3 points 9 at the beginning, 99 in the middle, and 999 at the end. Is it possible to do that?. I tried also with Ylim, but couldn't help

enter image description here

Upvotes: 2

Views: 55

Answers (2)

tashuhka
tashuhka

Reputation: 5126

Another solution:

F = [1 2 3];
Y = [9, 99 , 999];
Y_ = [9, (999-99)/2 , 999];

figure; 
subplot(1,2,1)
plot(Y,F,'*-');
set(gca,'XTickLabel',Y,'XTick',Y);
subplot(1,2,2)
plot(Y_,F,'o-');
set(gca,'XTickLabel',Y,'XTick',Y_);

You can see the difference:

enter image description here

Upvotes: 0

Schorsch
Schorsch

Reputation: 7895

You can change your y-axis to a logarithmic scale.
Use:

set(gca, 'YScale', 'log');

If you also set

ylim([9 999]);

as you had pointed out, you should get the desired result.

Upvotes: 2

Related Questions