Rotate stacked plot Labels to have them vertical - App Designer

조회 수: 53 (최근 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
Sahithi Kanumarlapudi 2019년 8월 16일
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!
hirdesh kumar pharasi
hirdesh kumar pharasi 2020년 6월 14일
편집: hirdesh kumar pharasi 2020년 6월 14일
True, only for that particular reason I am unable to use it

댓글을 달려면 로그인하십시오.

추가 답변 (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에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by