Graphing using matlab, need help!

edited November 2009 in Science & Tech
I am graphing 5 temperature curves and 1 heat curve onto 1 graph. I have the left axis as the temperature scale and the right axis as the heat scale. I usually use plotyy to graph 2 curves with different axis' but how would I graph 6 curves, 1 axis having 5 curves and the other axis having only 1 curve?

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited November 2009
    do something like this:

    plotyy(one temp curve and the heat curve);
    hold on;
    plot(the rest of the temp curves);
    hold off;
  • edited November 2009
    Thanks, I am now able to plot all on the same graph but I am facing another problem. I want each line to have it's own color. The code I have is below:

    M = csvread(filenameAndDir,1,0);
    t=M(:,1)/60;
    T=M(:,2);
    T1=M(:,3);
    T2=M(:,4);
    T3=M(:,5);
    T4=M(:,6);
    T5=M(:,7);
    A=M(:,8);

    [h]=subplot(2,1,[1,2]);
    annotation('textbox',[.5 .9 .1 .1],'edgecolor','none','string',filename);

    set(0,'DefaultAxesColorOrder',[0 1 0;1 0 1;0 0 1;1 0 0;1 1 0;0 0 0;0 1 1]);
    [AX,H1,H2]=plotyy(t,T,t,A);
    hold on;
    plot(t,T1,t,T2,t,T3,t,T4,t,T5);
    hold off;
    grid on;
    set(AX(1),'YLim',[20 120],'YTick', [20 40 60 80 100 120]);
    set(AX(2),'YLim',[0 100], 'YTick', [0 10 20 30 40 50 60 70 80 90 100]);
    ylabel(AX(1),'Temperature (C)')
    ylabel(AX(2),'Heat (kJ)')
    xlabel('Time (mins)')
    title('Heat Production')
    legend('Temp1','Temp2','Temp3','Temp4','Avg','Water','Heat',1);

    It is giving me 2 lines that are green and blue. How would I edit the code to make the colors to be as following:

    T-Green
    T1-Blue
    T2-Red
    T3-Yellow
    T4-Black
    T5-Cyan
    Q-Orange(it is magenta right now in the code because I don't know what the code is for orange)
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited November 2009
    after you call plotyy:

    set(H1,'color','g');
    set(H2,'color',[255 127 0]);


    and

    change plot(t,T1,t,T2,t,T3,t,T4,t,T5);

    to
    plot(t,T1,'b',t,T2,'r',t,T3,'y',t,T4,'k',t,T5,'c');


    I assumed that you meant the plot for A should be orange because i didn't see a variable Q.

    All this is in the doc files for plot and plotyy, btw.
Sign In or Register to comment.