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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Les Beckham
le 28 Fév 2025
Modifié(e) : Les Beckham
le 28 Fév 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.
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!