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

조회 수: 37 (최근 30일)
RS
RS 2015년 4월 16일
편집: pfb 2015년 4월 16일
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