Plotting on y-axis in form of offset for clarity ?

35 次查看(过去 30 天)
I have data A (first column x axis, and following column are y axis, trying to plot such that y axis have some offset for clarity), I don't want to put some additional value to this, without putting additional value, How can I plot directly on y axis, so that it will have some offset on y axis. Thanks.
plot(A(:,1),A(:,2));
hold on
plot(A(:,1),A(:,3)-0.3;
plot(A(;,1), A(:,4)+0.3;

回答(1 个)

pfb
pfb 2015-4-16
编辑:pfb 2015-4-16
your solution should work, provided you close the parentheses
plot(A(:,1),A(:,3)-0.3);
plot(A(;,1), A(:,4)+0.3);
didn't you get an error message?
  2 个评论
RS
RS 2015-4-16
编辑:RS 2015-4-16
yes, Is there any other methodology or something else, because sometime the guess value of 0.3 or 0.4 is too much for plot and plot changes to line form.
pfb
pfb 2015-4-16
编辑:pfb 2015-4-16
That is a bit too vague.
You're asking for a code that decides what is the optimal offset for producing a clear plot.
However "a clear plot" is kind of a subjective notion.
Have you considered alternatives, such as a waterfall plot? See
doc waterfall
Update note that waterfall works along rows
What I was suggesting above is to use a third dimension to "offset" your data. You can do that also with "plot3". Whether this produces an acceptable plot depends on your data and your personal taste.
About your original question, you could perhaps do something like this
hold on
plot(A(:,1),A(:,2));
os = max(A(:,2))-min(A(:,3));
plot(A(:,1),A(:,3)+os);
os = os+max(A(:,3))-min(A(:,4));
plot(A(:,1),A(:,4)+os);
and so on. You can put that in a loop, if you have many columns.

请先登录,再进行评论。

类别

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