Plotting on y-axis in form of offset for clarity ?
34 views (last 30 days)
Show older comments
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 Comments
Answers (1)
pfb
on 16 Apr 2015
Edited: pfb
on 16 Apr 2015
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 Comments
pfb
on 16 Apr 2015
Edited: pfb
on 16 Apr 2015
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.
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!