How to plat three similar figures together for comparison?

3 次查看(过去 30 天)
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