could anyone help me how to solve the issue

1 view (last 30 days)
I am getting the attached graph when i run the code.
In graph i want to remove zero with respect to y axis where as the rest of the values on y axis should remain same.
Could anyone please help me on this.
  3 Comments
Shashank Sharma
Shashank Sharma on 4 Jul 2019
Do you want to change the y limits ?
If so the function ylim can be used.
ylim( [ ymin, ymax ] )
In the above function if you set the ymin to be greater than 0. The 0 will no longer be displayed on the plot
jaah navi
jaah navi on 4 Jul 2019
x=[0.1 1 2 3 4]
y=[0.07 0.09 0.09 0.09 0.09]
z=[0.12 0.18 0.18 0.18 0.18]
l=[0.5 0.58 0.58 0.58 0.58]
m=[0.5 1 1 1 1]
plot(x,y,'-*')
hold on
plot(x,z,'-^')
hold on
plot(x,l,'-*')
hold on
plot(x,m,'-^')
hold on
xlim([0,4]);
set(gca,'XTick',[0:1:4]);
ylim([0,1.1])
set(gca,'YTick',[0:0.2:1.1])
I have used ylim([0,1.1]) so yaxis starts from 0.
what i actually need is y axis needs to start from 0 but 0 should not appear on the yaxis.
Could you please help me on this.

Sign in to comment.

Accepted Answer

Rik
Rik on 4 Jul 2019
Edited: Rik on 4 Jul 2019
If you want to not show a tick, you can remove it by explicitly skipping it.
ylim([0,1.1])
set(gca,'YTick',[0.2:0.2:1.1])
You can also choose to automatically remove the first tick after plotting:
ylim([0,1.1])
ticks=get(gca,'YTick');
set(gca,'YTick',ticks(2:end))
  3 Comments
jaah navi
jaah navi on 5 Jul 2019
it works.
Could you please help me how to skip the first tick from x axis initial point to forward to some distance as shown in attached figure.
Rik
Rik on 5 Jul 2019
You mean something like xlim([-0.1 3.1])?

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!