plotting functions with two y axes
Hello,
I have to plot two curves on the same graph, same x-axis and different y-axes (right and left). I can’t draw the curves with different hatching, different thickness and same black color. I would also like to insert the title of the axes and the legend. Below is the attempt script (R2021b).
Many thanks for the help
figure(1)
x1 = 0:0.1:10;
y1=10+x1.*4;
x2 = 0:0.1:10;
y2=15*sin(x2/2)
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,x1,y1,’-k’)
ax1.XColor = ‘k’;
ax1.YColor = ‘k’;
ax2 = axes(t);
plot(ax2,x2,y2,’–k’)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
gridHello,
I have to plot two curves on the same graph, same x-axis and different y-axes (right and left). I can’t draw the curves with different hatching, different thickness and same black color. I would also like to insert the title of the axes and the legend. Below is the attempt script (R2021b).
Many thanks for the help
figure(1)
x1 = 0:0.1:10;
y1=10+x1.*4;
x2 = 0:0.1:10;
y2=15*sin(x2/2)
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,x1,y1,’-k’)
ax1.XColor = ‘k’;
ax1.YColor = ‘k’;
ax2 = axes(t);
plot(ax2,x2,y2,’–k’)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
grid Hello,
I have to plot two curves on the same graph, same x-axis and different y-axes (right and left). I can’t draw the curves with different hatching, different thickness and same black color. I would also like to insert the title of the axes and the legend. Below is the attempt script (R2021b).
Many thanks for the help
figure(1)
x1 = 0:0.1:10;
y1=10+x1.*4;
x2 = 0:0.1:10;
y2=15*sin(x2/2)
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,x1,y1,’-k’)
ax1.XColor = ‘k’;
ax1.YColor = ‘k’;
ax2 = axes(t);
plot(ax2,x2,y2,’–k’)
ax1.XAxisLocation = ‘bottom’;
ax1.YAxisLocation = ‘left’;
ax2.XAxisLocation = ‘top’;
ax2.YAxisLocation = ‘right’;
ax2.Color = ‘none’;
ax1.Box = ‘off’;
ax2.Box = ‘off’;
grid plotting, plot yy MATLAB Answers — New Questions