Rotate stacked plot Labels to have them vertical - App Designer

26 次查看(过去 30 天)
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!
question.JPG

采纳的回答

Sahithi Kanumarlapudi
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 个评论
Bruce Vernham
Bruce Vernham 2019-11-25
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!

请先登录,再进行评论。

更多回答(1 个)

Adam Danz
Adam Danz 2020-11-19
编辑:Adam Danz 2023-5-17
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 个评论
Pedro
Pedro 2023-6-1
编辑:Pedro 2023-6-1
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
Adam Danz 2023-6-1
@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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by