WTH happened to "hold on all" in 2019b

figure;
plot(randn(10,2));
hold on all;
Error using hold (line 47)
First argument must be an axes object.
What happened to hold on all? That's so silly if you just removed it, why would I go back and change all my codes including it?
There is no problem on the 2019a.

8 Comments

Check the Release Notes, starting with the release after the one you are using. I noticed no changes in any of the hold functionality in the last few releases.
For sure there is something wrong!
Error using hold (line 47)
First argument must be an axes object.
According to the hold documentation, having both on and all is not supported.
That wasn't the case until 2019b version, one could definitely use "hold on all" and it was different than "hold on".
Other possibilities:
  • it's a bug in the current version, and you should report it
  • it was always a undocumented feature, in which case it is subject to removal without warning
I think the most constructive thing you could do is submit a bug report.
Baha411
Baha411 on 10 Oct 2019
Edited: Baha411 on 10 Oct 2019
Yeah maybe undocumented or a bug, I did report it, but for the time being I d need to modify it to "hold on". Thanks for your reply!
Why did you decide to go for hold all? It will be removed in a future release. Do you need to support releases that had the different effect? It may be a smarter idea to write a tiny wrapper function that uses something like ifversion to determine the appropriate syntax.
Sorry, I meant "hold on"

Sign in to comment.

 Accepted Answer

Baha411
Baha411 on 11 Oct 2019
I got an email regarding this from the technical support. For the sake of sharing the information, I am pasting it down here:
"
Thank you for the information. As noted in the documentation, "hold on" and "hold all" are the same. The "hold all" will be removed in a future release.
The command "hold on all" is equivalent to function syntax "hold('on','all')", which passes two arguments to the function "hold". The function "hold" is able to take two arguments, in which the first argument should be the axes object, and the second argument is either "on" or "off" (or "all"). In the example you provided, the function could not identify "on" as an axes object, that is why there is an error. Note that starting from MATLAB 2019b, the input checking is implemented.
"

More Answers (1)

Rik
Rik on 10 Oct 2019
Nowhere in the documentation could I find any mention of hold on all being a valid syntax. Before R2014b on and all had a different effect, but this changed in HG2. See the release notes.
If hold on all ever did not error, its behavior was not documented, similar to how hold off on doesn't have a documented behavior. Apparently they only now put in an explicit check for the documented two input syntax hold(ax,state).
This recent change might be connected to a behavior change for ColorOrder and LineStyleOrder, see the release notes with a wider search.
If you choose to use undocumented code and it worked for at least more than 5 year, be happy. Some undocumented code breaks much sooner.

3 Comments

Well I have been using
hold on all
I don't remember its specific purpose, but it is just disappointing that it doesn't work in the new version. Why has it been working if it was a wrong statement for years/decades? Anyways, I just need to modify my codes if I ever used it.
"I don't remember its specific purpose"
Nothing.
It never had a purpose (or atleast not for a very very long time).
I just checked MATLAB versions from R2009b to R2015b, and found that there are two ways that the hold code ignores more than one option:
  1. the code uses indexing to select the first option, and completely ignores any other options.
  2. Even if this were not the case, the code checks for 'on' before it checks for 'all', and once one option is matched any other options are simply ignored (if they even existed somehow in the relevant variable... which they don't at that point in the code).
So in reality, there has never been any point to using this undocumented snytax. So your code was and is equivalent to
hold on
"Why has it been working if it was a wrong statement for years/decades?"
Because code that does what it is documented to do is not the same thing as code that does not do anything undocumented. It is extremely hard to write code that has absolutely no undocumented evaluation paths, nor is such code likely to be easy to understand.
" it is just disappointing that it doesn't work in the new "
Because it never actually did anything, I don't see much reason for disappointment.
It seems that TMW just tightened up the input checking for unsupported, pointless syntaxes... which is probably a good thing.
Thanks for your detailed explanation Stephen!

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 10 Oct 2019

Commented:

on 12 Oct 2019

Community Treasure Hunt

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

Start Hunting!