how can I plot an increase and decrease in tempearture as x-axes (i.e. from 25 to 700, 700 to 500 all on x-axes), agains different y-axes
2 次查看(过去 30 天)
显示 更早的评论
load A
plot(A.T_bred,A.O2);hold on;
plot(A.T_bred,A.CO2);hold off;
0 个评论
采纳的回答
Star Strider
2023-1-13
编辑:Star Strider
2023-1-13
LD = load(websave('A','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1262340/A.mat'));
A = LD.A
figure
tiledlayout(1,2, 'TileSpacing','none') % Define Layout With No Spaces Between Tiles
nexttile
plot(A.T_bred,A.O2)
xlim([25 700])
nexttile
plot(A.T_bred,A.CO2)
xlim([500 700])
set(gca, 'XDir','reverse') % Reverse X-Axis Direction In Second Tile Plot
I am not certain what you want to do, however this should get you started.
EDIT — (13 Jan 2023 at 16:54)
Sorting ‘T_bred’ and plotting against it —
As = sortrows(A,4) % Sort On 'T_bred'
figure
tiledlayout(1,2, 'TileSpacing','none') % Define Layout With No Spaces Between Tiles
nexttile
plot(As.T_bred,As.O2)
xlim([25 700])
nexttile
plot(As.T_bred,As.CO2)
xlim([500 700])
set(gca, 'XDir','reverse') % Reverse X-Axis Direction In Second Tile Plot
[T_bredU,idx] = unique(A.T_bred, 'sort'); % Unique Sorted Values Of 'T_bred' & Indices Of First Instances
Au = A(idx,:); % Sort On 'idx'
figure
tiledlayout(1,2, 'TileSpacing','none') % Define Layout With No Spaces Between Tiles
nexttile
plot(Au.T_bred,Au.O2)
xlim([25 700])
nexttile
plot(Au.T_bred,Au.CO2)
xlim([500 700])
set(gca, 'XDir','reverse') % Reverse X-Axis Direction In Second Tile Plot
This plots and as fuctions of ‘T_bred’ sorted by ‘T_bred’. My code is otherwise unchanged.
Where do you want to go from here (since I do not understand what you want to do)?
[T_bredMax,maxidx] = max(A.T_bred)
idx1 = 1:maxidx;
idx2 = maxidx:size(A,1);
figure
tiledlayout(1,2, 'TileSpacing','none') % Define Layout With No Spaces Between Tiles
nexttile
plot(A.T_bred(idx1),A.O2(idx1))
hold on
plot(A.T_bred(idx1),A.CO2(idx1))
hold off
xlim([25 650])
ylim([0 45])
nexttile
plot(A.T_bred(idx2),A.O2(idx2))
hold on
plot(A.T_bred(idx2),A.CO2(idx2))
hold off
xlim([500 650])
set(gca, 'XDir','reverse') % Reverse X-Axis Direction In Second Tile Plot
figure
tiledlayout(1,2, 'TileSpacing','none') % Define Layout With No Spaces Between Tiles
nexttile
plot(A.T_bred(idx1),A.O2(idx1))
hold on
plot(A.T_bred(idx1),A.CO2(idx1))
hold off
xlim([25 650])
ylim([0 45])
nexttile
plot(A.T_bred(idx2),A.O2(idx2))
hold on
plot(A.T_bred(idx2),A.CO2(idx2))
xline(500, '-k')
hold off
xlim([500 650])
Axr = gca;
Axr.XDir = 'reverse'; % Reverse X-Axis Direction In Second Tile Plot
Axr.YAxis.Visible = 'off';
Axr.YTick = [];
This looks like it could approach what you want. I cannot turn off the y-axis ticks on the right plot (in the centre here), even thougu that should be possible. I am not certain how to deal with the x-axis tick values or labels, so I left them as they are.
.
0 个评论
更多回答(2 个)
Kevin Holly
2023-1-13
Did you want something like this?
load A
yyaxis left
plot(A.T_bred,A.O2);
yyaxis right
plot(A.T_bred,A.CO2);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!