I am trying to use plotyy to specify the axes on a graph but I am struggling to figure out how to use it
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
A Poyser
am 28 Feb. 2025
Beantwortet: A Poyser
am 3 Mär. 2025
I am plotting a graph that uses semilog and plot and I want to specify the left and right axes as they use different units.
%% Set up the Import Options and import the data
opts = spreadsheetImportOptions("NumVariables", 5);
% Specify sheet and range
opts.Sheet = "Sheet1";
opts.DataRange = "Z1:AD202";
% Specify column names and types
opts.VariableNames = ["PressureMpa", "PoreDiameternm", "CumulativePoreVolumemLg", "SmoothedDVdlogDPoreVolumemLg", "OfTotalIntrusionVolume"];
opts.VariableTypes = ["double", "double", "double", "double", "double"];
% Import the data
mean = readtable("mean.xlsx", opts, "UseExcel", false);
%% Clear temporary variables
clear opts
figure
% Create axes
axes1 = axes('Parent',figure);
hold(axes1,'on');
semilogx(mean.PoreDiameternm(1:92),mean.SmoothedDVdlogDPoreVolumemLg(1:92),'DisplayName','Pore Size Distribution')
semilogx(mean.PoreDiameternm(1:92),mean.OfTotalIntrusionVolume(1:92),'LineStyle','-','Color','r','DisplayName','% Of Total Intrusion Volume');
% Activate the right side of the axes
yyaxis(axes1,'right');
set(axes1,'YColor',[0 0 0]);
% Uncomment the following line to preserve the Y-limits of the axes
% ylim(axes1,[0 0.2]);
ylabel('Smoothed dV/dlogD Pore Volume (mL/g)','Interpreter','latex')
yyaxis(axes1,'left');
% Uncomment the following line to preserve the Y-limits of the axes
% ylim(axes1,[0 0.2]);
ylabel('% Of Total Intrusion Volume','Interpreter','latex')
xlabel('Pore Diameter nm','Interpreter','latex')
hold(axes1,'off');
% Set the remaining axes properties
set(axes1,'XDir','reverse','XMinorTick','on','XScale','log');
Any help would be greatly aprreciated
edit, made it % of total volume as opposed to cumulative volume so my problem makes a little more sense
and I reuploaded my data
4 Kommentare
Les Beckham
am 28 Feb. 2025
Bearbeitet: Les Beckham
am 28 Feb. 2025
Unless you provide valid data (non-NaN), you are going to have a hard time getting help with plotting it. Did you read all of my comments? Your updated code has not addressed all of those issues.
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Title 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!