Change the width of the plot

22 Ansichten (letzte 30 Tage)
Afsher P A
Afsher P A am 30 Jan. 2022
Bearbeitet: Afsher P A am 1 Feb. 2022
How to change the line width of plot y3 ?
% Create some data to work with
x = 0:100:1000;
y1 = [0 137.9 288 442 598.1 755.5 913.7 1072 1231 1390 1600];
y2 = [NaN 61.93 30.95 20.62 15.46 12.368 10.309 8.83 7.73 6.868 6];
y3 = [0 3.229 6.461 9.697 12.93 16.17 19.4 22.65 25.87 29.12 33.33];
% Plot on the left and right y axes
figure
ax1 = axes;
yyaxis left % see [1]
plot(x,y1,'linewidth',1.5)
pause(0.1) % see [3]
% set the y(left) and x tick values, make them permanent
% This is the tricky part and shoudl receive a lot of thought when
% you adapt this to your code...
ax1.XTickMode = 'manual';
ax1.YTickMode = 'manual';
ax1.YLim = [min(ax1.YTick), max(ax1.YTick)]; % see [4]
ax1.XLimMode = 'manual';
grid(ax1,'on')
ytick = ax1.YTick;
yyaxis right % see [1]
plot(x,y2,'linewidth',1.5)
% create 2nd, transparent axes
ax2 = axes('position', ax1.Position);
plot(ax2,x,y3, 'k')
pause(0.1) % see [3]
ax2.Color = 'none';
grid(ax2, 'on')
% Horizontally scale the y axis to alight the grid (again, be careful!)
ax2.XLim = ax1.XLim;
ax2.XTick = ax1.XTick;
ax2.YLimMode = 'manual';
yl = ax2.YLim;
ax2.YTick = linspace(yl(1), yl(2), length(ytick)); % see [2]
% horzontally offset y tick labels
ax2.YTickLabel = strcat(ax2.YTickLabel, {' '});
% [1] https://www.mathworks.com/help/matlab/ref/yyaxis.html
% [2] this is the critical step to align the grids. It assumes both
% axes contain ticks at the start and end of the y axis
% [3] For some reason when I step through the code, the plots appear
% as they should but when I run the code at it's natural speed
% there are graphics issues. It's as if code execution is
% ahead of the graphics which is annoying. A brief pause
% fixes this (r2019a)
% [4] Scaling is easier if the ticks begin and end at the axis limits
  2 Kommentare
Adam Danz
Adam Danz am 30 Jan. 2022
Bearbeitet: Adam Danz am 30 Jan. 2022
Afsher P A
Afsher P A am 1 Feb. 2022
Yes Sir. That's why I shared the question to you personally.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 30 Jan. 2022
Replace this line:
plot(ax2,x,y3, 'k')
with
plot(ax2,x,y3, 'k','LineWidth',5)

Weitere Antworten (0)

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by