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;
0 个评论
回答(1 个)
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 个评论
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!