How to set default legend properties in R2017a?

I have seen solutions to this question that seem to no longer apply for R2017a.
The 'Legend' Illustration Object has a 'AutoUpdate' Text Property that is breaking all the plot routines that I have written over the years. I would very much like to set the default to 'off'.
The following does not work:
>> set(groot,'LegendAutoUpdate','off')
Error using matlab.ui.Root/set
There is no LegendAutoUpdate property on the Root class.
>> set(groot,'factoryLegendAutoUpdate','off')
Error using matlab.ui.Root/set
Factory properties can only be queried, not set.
>> set(0,'LegendAutoUpdate','off')
Error using set
There is no LegendAutoUpdate property on the Root class.
I don't want to wait until I instantiate and have a Legend handle.
I want to change the default.

6 Comments

This works:
set(0,'DefaultLegendAutoUpdate','off')
Yes this works once a session is started, but it gets overridden if I put it in the startup.m script.
This seems to be a "feature that won't go away". :-(
It is not possible to permanently change default properties; startup script is about the closest you can get.
I do not know why it would not work in a startup script through -- unless perhaps you have multiple startup scripts ?
I just have the one startup.m script. It changes from the default directory to a directory for SVN working directories.
I put the following in, both before and after the change of directory.
MATLAB code:
disp('Setting ''DefaultLegendAutoUpdate'' to ''off'' now.')
set(0,'DefaultLegendAutoUpdate','off')
get(0,'DefaultLegendAutoUpdate')
The comment never displays, even though the 'pwd' does display.
MATLAB code:
cd ../../svnWork
addpath('.')
pwd
So for now I just add the set(0,'DefaultLegendAutoUpdate','off') command to the beginning of any plot script that is giving me trouble, so that's ok. After the first occurrence, it isn't needed again anyway.
I tried putting a 'clean-up' routine after the plotting, but changing 'AutoUpdate' to 'off' doesn't turn off the added items. That actually makes sense.
The earlier solution works for me: if I execute the following line at either the command line or in my startup.m file,
set(0,'DefaultLegendAutoUpdate','off')
then I don't get 'data1', 'data2' entries for the code in my question here. I will add that I am running R2018b.
blues
blues on 28 Feb 2020
Edited: blues on 28 Feb 2020
Thanks for this trick. It appears in version R2019b as well.

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 29 Aug 2017

Edited:

on 28 Feb 2020

Community Treasure Hunt

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

Start Hunting!