Filter löschen
Filter löschen

Plotyy with trend lines

2 Ansichten (letzte 30 Tage)
Bahram
Bahram am 23 Apr. 2012
Hi,
I am trying to plot two sets of data on two different y axes, and also plot the trend lines for both sets of data.
Here are the data sets:
x axis date_x_axis
y-axis 1 strain(1:end,1)
y-axis 2 temperature(1:end,1)
trend line for y-axis 1 strain_trend
trend line for y-axis 12 temp_trend
I've used the following code.
figure1=figure ('Name','G01 & Temp.');
hold('on')
%Actual data
[AX,H1,H2] = plotyy(date_x_axis,strain(1:end,1),date_x_axis,temperature(1:end,1));
grid('on')
set(gca,'GridLineStyle','--','LineWidth',1)
set(gca,'XMinorTick','on')
set(H1,'Color','black')
set(H2,'Color','red')
set(H1,'Linewidth',1)
set(H2,'Linewidth',1)
set(AX,{'ycolor'},{'black';'black'})
set(AX,'Fontsize',fontsize_axis)
set(AX,'FontName',fontname)
set(get(AX(1),'Ylabel'),'String','Strain (\mu strain)','Fontsize',...
fontsize_label,'Fontname',fontname)
set(get(AX(2),'Ylabel'),'String','Temperature (oF)','Fontsize',...
fontsize_label,'Fontname',fontname)
xlabel('DATE')
title('G01')
legend(AX(1),'Strain','Temperature','Location','Best')
datetick(AX(1),'x','mm/dd/yy')
datetick(AX(2),'x','mm/dd/yy')
%Trend lines
[AXX,H3,H4] = plotyy(date_x_axis,strain_trend,date_x_axis,temp_trend);
set(H3,'Color','black')
set(H4,'Color','red')
set(H3,'Linewidth',1.1)
set(H4,'Linewidth',1.1)
set(AXX,{'ycolor'},{'black';'black'})
datetick(AXX(1),'x','mm/dd/yy')
datetick(AXX(2),'x','mm/dd/yy')
The trend line plots put numbers on the axes, and these numbers mess things up. Could you tell me how I can add the trend lines without plotting axes?
Thanks for your time.
  1 Kommentar
Oleg Komarov
Oleg Komarov am 23 Apr. 2012
Please, format your question as shown here: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 24 Apr. 2012
I do not recommend using two plotyy() calls for the same area (with "hold on"). I recommend instead using plotyy() once, and then taking the two axes returned and plot() or line() appropriately against each of those axes.

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by