Greek letters and symbols in stacked plots

13 views (last 30 days)
Hi everyone,
I'm trying to create a stacked plot with the stackedplot() function.
I have the X vector of values and four series of Y values as columns of a matrix. Is it possible to insert tex symbols in y axes labels?
I tried the following lines, but, can't introduce special characters.
X = linspace(0,1,1000);
Y = rand(length(X),4);
txt3 = '\Delta E_{m=3}';
txt4 = '\Delta E_{m=4}';
txt6 = '\Delta E_{m=6}';
txt8 = '\Delta E_{m=8}';
newYlabels = {txt3, txt4, txt6, txt8};
newXlabel = 't [s]';
sss = stackedplot(X,Y,'DisplayLabels',newYlabels,'xlabel',newXlabel);
grid on
Thanks to anyone who wants to help me!
  1 Comment
Walter Roberson
Walter Roberson on 1 Nov 2020
There is no documented way to control that. The stackedplot call returns a Stackedplot object which contains a property that allows you to control some of the y-axis properties, but only 4 things can officially be changed.
I am not at my desk so I cannot currently investigate what hidden properties are available.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 4 Nov 2020
If you take
sssax = sss.NodeChildren(end/2+1:end);
then the result is a column vector of the axes that were created to display the objects.
You can then
for K = sssax.'; K.YLabel.Interpreter = 'tex'; end
and the label will change.
  3 Comments
Walter Roberson
Walter Roberson on 15 Mar 2021
That's a good question. When I experiment in Livescript, I find that changes I make to the axes after the stack plot do not seem to matter -- I can outright clear the axes and it doesn't change what is already displayed.
Aman Maskay
Aman Maskay on 16 Mar 2021
Thanks for lookin into this.
Thats interesting. Seems like a bug.

Sign in to comment.

More Answers (0)

Categories

Find more on Formatting and Annotation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!