How do I make the second graph look like the first?
Show older comments
Hi I am writing code to automatically generate graphs from an excel file and am wondering how I miraculously made the first graph look how it is and not the second one.
<<


>>
I would like the second graph to be all the same colour with different line styles. How do I do this? Here is an excerpt of my code
freqCounter=1; tempCounter=1; legendCounter=1;
firstDataSheet=2;
sheet=firstDataSheet;
PvsA=figure('Name','Power versus Current','NumberTitle','off');
SlopevsA=figure('Name','Slope (W/A) versus Current','NumberTitle','off');
cmap=colormap(lines(combinations));
for k=1:combinations
%need to modify the right hand side of the colon to find end of the
%data Current= xlsread(path,sheet,['B2:B' num2str(unique+1)]);
PeakPower= xlsread(path,sheet,['E2:E' num2str(unique+1)]);
beepboop=xlsread(path,sheet,['H5:H' num2str(unique+1)]); offsetLambda=xlsread(path,sheet,'H2');
deltaT=(beepboop-offsetLambda)/lambdaK; %pre offset
offset=deltaT(1);
deltaT=deltaT+offset*-1;Slope=PeakPower/Current;
figure(PvsA)
yyaxis left
plot(Current,PeakPower)
hold on
yyaxis right
plot(Current(4:end),deltaT)
hold on figure(SlopevsA)
plot(Current,Slope)
hold onsheet=sheet+sheetsToSkip;
end
%adding labels to the graph figure(PvsA)
title('Peak Power versus Current and delta T vs Current')
yyaxis left
xlabel('Current (A)')
ylabel('Peak Power (W)')
yyaxis right
ylabel('delta T')
6 Comments
Well, obviously the second one is plotted on a single axes whereas in the first case you (or whoever wrote the script) used yyaxis to call a second yaxis. Do you even have two quantities in the second case? I mean, you only have one plot...
figure(SlopevsA)
plot(Current,Slope)
hold on
Rik
on 1 Oct 2018
If you found yyaxis but didn't read the doc of plot, I suspect you copied the code from somewhere. Matlab doesn't do magic, so you can learn how you need to use the functions by reading the documentation.
PromoCodeBSJ
on 1 Oct 2018
PromoCodeBSJ
on 1 Oct 2018
PromoCodeBSJ
on 1 Oct 2018
jonas
on 1 Oct 2018
Interesting... it seems to be a feature of the yyaxis... I'll formulate an actual answer instead.
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D 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!