Seperating YAxis Ticks/Labels from Axes
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I recently found plotNy, which allows users to have more than two YAxes Ticks/Labels on the same side of the axes (left). This has been useful as in my industry it is often required to view a large number of variables on the same axes component. PlotNy essentially just overlays multiple axes elements and then pulls the lines from the numerous axes components to the last created axes that sits on top of the rest.
I created an app using App Designer and managed to embed the contents of the figure that plotNy generates into a panel within my app. Some re work is required to re-position the axes and Y axis ticks/labels nicely, which I won't show below to keep things concise. When the user adds more variables to the axes, the overall size of the axes is reduced to make space for the additional YAxis Ticks & Labels, which makes good sense. However, because I require a large number of variables to be added to the axes, I end up with a Panel that contains a very small axes component and a large space for all of the required YAxis Ticks/Labels.
My question is, would it be possible to somehow seperate the YAxis Ticks/Labels from the axes itself?
The idea here would be to place the YAxis Ticks/Labels in a seperate, horizontally scrollable panel, that sits directly to the left of the Panel which contains the axes component.
This is how the Axes & YAxis Ticks/Labels look when plotting multiple variables (Screenshot of panel, not whole app)

The below code shows how I call PlotNy and send it over to the Panel (app.Panel) within the app.
app.h3i = plotNy(plotData{:}, 'YAxisLabels', legendStrings, 'LineColor', app.linecolors, 'Ylim', app.adjustedYLims);
for i=1:length(app.h3i.ax)
set(app.h3i.ax(i),'ycolor',app.linecolors{i});
end
tempFig = figure('Visible', 'off');
children = app.h3i.parent.Children;
allAxes = [];
for i = 1:length(children)
if isa(children(i), 'matlab.graphics.axis.Axes')
allAxes = [allAxes; children(i)];
end
end
app.newAxes = gobjects(size(allAxes));
for i = 1:length(allAxes)
app.newAxes(i) = copyobj(allAxes(i), tempFig);
end
for i = 1:length(app.newAxes)
app.newAxes(i).Parent = app.Panel;
end
2 comentarios
dpb
el 7 de Feb. de 2025
My idea would be to do two separately but with one with no data but the axes so you can shring its active area to nothing. The other with the data would then make the y-axes labels invisible so you can put the left on top.
I don't know about the panning, though...
Respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Programming 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!