divide matlab line plot in two lines of the same colour

6 views (last 30 days)
Hi I am trying to plot a graph in the code below. Does anyone know how to split the "azimuth_summer_solstice" and "altitude_summer_solstice" line. As the data is, there are two curves on either side of the graph which are connected. I want to remove this connecting line and show the winter_solstice as two separate curves
My code is
if Y = xlsread('hanimaadhoo_sun_path.xls','hanimaadhoo'); %
azimuth_march_equinox = Y(1:17,1);
altitude_march_equinox = Y(1:17,2);
azimuth_september_equinox = Y(1:17,3);
altitude_september_equinox =Y(1:17,4);
azimuth_winter_solstice = Y(1:17,5);
altitude_winter_solstice = Y(1:17,6);
azimuth_summer_solstice = Y(1:17,7);
altitude_summer_solstice = Y(1:17,8);
The azimuth_summer_solstice is
[60.6 64.9 67.5 68.7 68.7 67.0 62.1 49.3 11.6 319.2 298.1 290.6 287.7 287.0 287.6
289.5 292.9]
The altitude_summer_solstice is
[ -28.20 -14.6 -0.5 13.2 27.2 41.22 54.9 67.6 76.1 72.5 60.9 47.60 33.7 19.6 5.6 -8.3 -22.08]
figure;
plot(azimuth_summer_solstice,altitude_summer_solstice,azimuth_winter_solstice,altitude_winter_solstice,...
azimuth_march_equinox,altitude_march_equinox,azimuth_september_equinox,altitude_september_equinox,'LineWidth',2);
  2 Comments
Wayne King
Wayne King on 22 Sep 2012
Since this matrix is only 17x8, or at least the part you're using here, can you just post the matrix. It would be really helpful in this case.
Andrew Alkiviades
Andrew Alkiviades on 22 Sep 2012
Wayne, I have updated my original question. hope it helps!

Sign in to comment.

Answers (2)

Wayne King
Wayne King on 23 Sep 2012
Edited: Wayne King on 23 Sep 2012
Do you need to plot these with a line? Typically when you plot data like this you would just use a scatter plot
plot(azimuth_summer_solstice,altitude_summer_solstice,'b^',...
'markerfacecolor',[0 0 1]);
Or maybe a stem plot:
h = stem(azimuth_summer_solstice,altitude_summer_solstice,...
'fill','--');
set(get(h,'BaseLine'),'LineStyle',':')
set(h,'MarkerFaceColor','red')
  1 Comment
Andrew Alkiviades
Andrew Alkiviades on 23 Sep 2012
ideally this has to be done with a line! I understand your point about the scatter though

Sign in to comment.


Wayne King
Wayne King on 23 Sep 2012
You can easily break up the data where there is clear jump in the azimuth: 68.7000 to 287.0000
To do this you sort the azimuth data, but keep the indices from the sort. You then sort the altitude data using those indices so you keep the correspondence between the two variables.
[az_ss,I] = sort(azimuth_summer_solstice);
al_ss = altitude_summer_solstice(I);
plot(az_ss(1:9),al_ss(1:9),'b');
axis([0 320 -30 70]);
hold on;
plot(az_ss(10:end),al_ss(10:end),'b');
Without a clearer picture of the rest of the data or the ultimate goal, it's hard to be more of a help than that.
  1 Comment
Andrew Alkiviades
Andrew Alkiviades on 23 Sep 2012
Thanks Wayne, but I can seem to position the other three lines on that graph as well. could you suggest how to do all the lines simultaneously on the same graph

Sign in to comment.

Categories

Find more on Discrete Data 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!