How to plat three similar figures together for comparison?

조회 수: 3 (최근 30일)
jfrazie9
jfrazie9 2018년 3월 29일
댓글: Star Strider 2018년 3월 29일
I am trying to plot three sets of data together where both A sets go together, both B sets go together and both C sets go together. The way I am doing it I only get the A sets to appear on the figure. What am I doing wrong or need to change so that these data sets all appear on the same figure to compare versus one another?
plot(medianVsA(:,1),medianDepthA(:,1),medianVsB(:,1),medianDepthB(:,1),medianVsC(:,1),medianDepthC(:,1),'b','linewidth',2.5);
hold on
Thank you for the help in advance.

답변 (2개)

Star Strider
Star Strider 2018년 3월 29일
Without your data it is not possible to determine what the problem may be.
However, you are telling plot to use a blue line for all of the data. Use the default color line progression and they will plot in different colours.
Example
A = [(1:10)' rand(10,1)];
B = [(1:10)' rand(10,1)];
figure
plot(A(:,1), A(:,2), B(:,1),B(:,2), 'b')
title('Blue Lines For All Data')
figure
plot(A(:,1), A(:,2), B(:,1),B(:,2))
title('Default Line Color Progression')

jfrazie9
jfrazie9 2018년 3월 29일
Attached are the two data sets from A that I am trying to plot. These are just copied out of matlab into a *.txt file format. I have them all as *.m files. In addition to this I have the EXACT data type for B, meaning medianVsB.m and medinaDepthB.m are 2 additional 26x1 doubles. Also I have similar data fro C in medianVsC.m and medianDepthC.m, however these are both 14x1 doubles. I am trying to plot all three on the same plot where the data for medianDepthX.m is the y-axis and medinVsX.m is the x-axis.
  댓글 수: 2
jfrazie9
jfrazie9 2018년 3월 29일
A=medianVsA;
B=medianDepthA;
C=medianVsB;
D=medianDepthB;
E=medianVsC;
F=medianDepthC;
plot(A(:,1),B(:,1),C(:,1),D(:,1),E(:,1),F(:,1));
Running this is just plotting 2 lines. That is my hang up and confusion. Thank you for your help in advance.
Star Strider
Star Strider 2018년 3월 29일
The range of your data are extreme. For example, 'medianDepthA' goes from 0.855 to 69, and then jumps at the end to 1E+99. (Also, ‘medianVsA’ in the files you posted is one element longer than 'medianDepthA'.)
When in doubt, plot with markers, since it makes your data easier to see:
figure
plot(medianVsA(1:end-1), medianDepthA, '-p')
Including the extra dimension is redundant, although the plot is correct:
plot(medianVsA(1:end-1,1), medianDepthA(:,1), '-p')
That is the only problem I see.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by