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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
A Poyser
el 28 de Feb. de 2025
Respondida: A Poyser
el 3 de Mzo. de 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 comentarios
Les Beckham
el 28 de Feb. de 2025
Editada: Les Beckham
el 28 de Feb. de 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.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!