How do I shift ONLY the y axis in a plot?

5 次查看(过去 30 天)
Hello,
I want to create a graph where y runs from 0 to 500 with intervals of 20 and x runs from -0.3 to 0.3 with intervals of 0.1 each. I have written the following code which plots the graph:
% Plot for lambda = 0.5
n = 30;
dc1 = 1/30*(0.5*66+0.5*62);
dc2 = 1/30*(0.5*57+0.5*55);
dn1 = 1/30*(0.5*40+0.5*30);
dn2 = 1/30*(0.5*35+0.5*20);
dn3 = 1/30*(0.5*20+0.5*27);
e = -0.3:0.01:0.3;
bc1 = 30*dc1*(1+(dc1./(10+e)));
bc2 = 30*dc2*(1+(dc2./(10+e)));
bn1 = 30*dn1*(1+(dn1./(2+e)));
bn2 = 30*dn2*(1+(dn2./(2+e)));
bn3 = 30*dn3*(1+(dn3./(2+e)));
plot(e, bc1, 'g')
hold all
plot(e, bc2, 'r')
hold all
plot(e, bn1, 'b')
hold all
plot(e, bn2, 'y')
hold all
plot(e, bn3, 'black')
When I run this, a normal graph with the y axis at the left appears. What should I add to the code so that I can shift only the y axis at (0,0)such that (1) there's no change in the x axis, (2) no negative y axis appears.
Thank you!
  4 个评论
Walter Roberson
Walter Roberson 2016-11-6
Note: the answer suggested by mohit kumar is for R2014b or later.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2013-4-7
  1 个评论
Sam
Sam 2013-4-7
Hello
I am unable to use the file to shift my axis to the center. When I add PlotAxisAtOrigin(0,0); the y axis disappears completely. I am quite new at Matlab, I will be grateful if you could help me by telling me how to run the file.
Thank you.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by