Subscript in stackedplot DisplayLabels

37 views (last 30 days)
Sebastian Sprunck
Sebastian Sprunck on 18 Jul 2019
Edited: Adam Danz on 1 Aug 2019
Hello everyone,
I'm trying to build a stacked plot with 3 graphs using Matlab 2018b's stackedplot-function. I'd like to write the corresponding DisplayLabels in TeX-style so that I can use subscripts, as can be done in regular plots without problem using e.g.
When I create a stackedplot using below code though, the labels are printed 'as is' instead of as a subscript:
s = stackedplot(f,If,'DisplayLabels',{'T_{r} = 50 ns','T_{r} = 20 ns','T_{r} = 10 ns'});
I've tried accessing Interpreter-properties and even setting
but couldn't get it to work as intended.
Can anyone please tell me how to do that?
Best regards
Adam Danz
Adam Danz on 30 Jul 2019
Yeah, there are a few newer plotting functions that have a bunch of features on lockdown such as heatmap() and stackedplot(). I avoid using them which is unfortunate since they have some nice added features but when you can edit the basic, they become less useful.

Sign in to comment.

Accepted Answer

Yair Altman
Yair Altman on 31 Jul 2019
You can access the individual stacked-axes' properties via the hidden sub-property Axes of the stackedplot's AxesProperties property, and then modify the YLabel's Interpreter property to 'tex' or 'latex' (it's 'none' by default).
For example, to change the middle (2nd) YLabel:
s = stackedplot(...);
axesProps = struct(s.AxesProperties(2)); % using struct() is undocumented
axesProps.Axes.YLabel.Interpreter = 'tex';
Note that using struct() to access internal object properties is undocumented.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by