Rotate stacked plot Labels to have them vertical - App Designer
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Andrea Quintarelli
il 13 Ago 2019
Commentato: Adam Danz
il 1 Giu 2023
Hi,
i am using stacked plots in App Designer to visulize some data and i would love to rotate the labels on the left side of these plots, having them in vertical direction.
Does Anybody know if this is possible at all with stacked plots?
Thank you very much!
0 Commenti
Risposta accettata
Sahithi Kanumarlapudi
il 16 Ago 2019
For normal plots ‘ytickangle’ can be used in order to rotate the y-axis label.
But in case of stacked plots y-axis labels are treated as ‘DisplayLabels’ and their orientation cannot be changed.
3 Commenti
Bruce Vernham
il 25 Nov 2019
If that is the case than this feature is completely usless for displaying data and not worth the time and effort to implement the code!
hirdesh kumar pharasi
il 14 Giu 2020
Modificato: hirdesh kumar pharasi
il 14 Giu 2020
True, only for that particular reason I am unable to use it
Più risposte (1)
Adam Danz
il 19 Nov 2020
Modificato: Adam Danz
il 17 Mag 2023
You can get the axis handles in stackedplot using the undocumented NodeChildren property. Then rotate and center the labels.
rng('default')
h = stackedplot(rand(100,4));
drawnow
ax = findobj(h.NodeChildren, 'Type','Axes');
set([ax.YLabel],'Rotation',90,'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom')
5 Commenti
Pedro
il 1 Giu 2023
Modificato: Pedro
il 1 Giu 2023
For some reason this is not working for me on MATLAB 2023a running on Windows 11. I also want to change the interpreter for the Y axis to 'tex'. I don't know if it changes anything but I'm using a LiveScript with Output on Right.
This is my code:
figure;
opts.str = 'AE monitoring results 2022-06-14 16:42:40 [120 kN]';
opts.s = stackedplot(MainTT,RateTT,bValueTT,opts.vars,"LegendVisible","off",...
"GridVisible","on",'Title',opts.str);
drawnow
opts.c = parula(numel(opts.s.LineProperties));
opts.ax = findobj(opts.s.NodeChildren,'Type','Axes');
set([opts.ax.YLabel],'Rotation',90,'HorizontalAlignment', ...
'Center', 'VerticalAlignment', 'Bottom', 'Interpreter','tex');
for ii=1:numel(opts.s.LineProperties)
opts.s.LineProperties(ii).MarkerEdgeColor = "k";
opts.s.LineProperties(ii).MarkerFaceColor = opts.c(ii,:);
opts.ax(ii).XAxis.Exponent = 0; %turn off scientific notation on axis
end
% Adjust individual graphs
% Make every graph from 2 to 'n' scatter
for ii = 2:numel(opts.s.LineProperties)
opts.s.LineProperties(ii).PlotType = "scatter";
opts.s.LineProperties(ii).MarkerFaceColor = opts.c(ii,:);
end
% AccumRate
opts.s.AxesProperties(1).LegendLabels = {'cum AE'};
% Rate
opts.s.AxesProperties(2).LegendLabels = {'AE/sec'};
% Frequency
opts.s.AxesProperties(3).YLimits = [0 1000];
opts.s.AxesProperties(3).LegendLabels = {'f (kHz)'};
% Amplitude
opts.s.AxesProperties(4).YLimits = [0 140];
opts.s.AxesProperties(4).LegendLabels = {'A (dB)'};
% beta_t
opts.s.LineProperties(end-1).PlotType = 'plot';
opts.s.LineProperties(end-1).LineStyle = '--';
opts.s.LineProperties(end-1).Color = 'k';
opts.s.LineProperties(end-1).Marker = 'o';
opts.s.LineProperties(end-1).MarkerFaceColor = opts.c(end-1,:);
opts.s.LineProperties(end-1).MarkerEdgeColor = 'k';
opts.s.AxesProperties(end-1).LegendLabels = {'\Beta_t'};
% b-Value
opts.s.LineProperties(end).PlotType = 'plot';
opts.s.LineProperties(end).LineStyle = '--';
opts.s.LineProperties(end).Color = 'k';
opts.s.LineProperties(end).Marker = 'o';
opts.s.LineProperties(end).MarkerFaceColor = opts.c(end,:);
opts.s.LineProperties(end).MarkerEdgeColor = 'k';
opts.s.AxesProperties(end).YLimits = [0.5 2];
opts.s.AxesProperties(end).LegendLabels = {'b-value'};
clear opts ii
And this is my output
Also the Interpreter seems to be changing just for the title (which is not what I want).
When I copy and run your code it works as intendend. My guess is that some of my other property settings is interfering with the set function, but I can't grasp what it is.
Adam Danz
il 1 Giu 2023
@Pedro when using undocumented features there's no guarantee that they will always work. Figures generated in live scripts behave differently and don't support these undocumented features.
I recommend writing to tech support to request an interpreter property in stackedplot as well as having access to the axes label handles. Go to Contact Support > Report a Bug > Select Technical Support & Product help, bugs, suggestions.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!