Matlab 2017b plotting error.

16 views (last 30 days)
Catalin Tudoran
Catalin Tudoran on 13 Jan 2018
Edited: Andrea Gargano on 8 Jul 2018
I can't plot anything. My error is:
No appropriate method, property, or field 'Type' for class 'matlab.graphics.GraphicsPlaceholder'.
Error in newplot>ObserveAxesNextPlot (line 134)
if ~strcmp(fig.Type,'figure')
Error in newplot (line 89)
ax = ObserveAxesNextPlot(ax, hsave);
Error in blabla (line 11)
plot(x,e);
Help me, please.
  4 Comments
Jan
Jan on 13 Jan 2018
@Catalin: Please use the "{} Code" button to format code. This is nicer than inserting blank lines.
Star Strider
Star Strider on 13 Jan 2018
Your code, as you posted it, runs without error for me in R2017b.

Sign in to comment.

Accepted Answer

Jan
Jan on 13 Jan 2018
This is not the expected behavior. It is strange, that the parent of the axes is a matlab.graphics.GraphicsPlaceholder and not a figure or uipanel. This should never happen. So I ask the standard questions:
  • Did it work any time before?
  • What did you change since it worked?
  • Did you shadow any built-in functions, e.g. figure, axes etc.? If so, don't do this. Add folders with user defined function at the bottom of the path only, never on top where they can shadow built-in function and cause a strange behavior.
  • Is this a fresh install of Matlab? Which version and which OS?
  5 Comments
Jan
Jan on 8 Feb 2018
I assume, this is caused by a user-defined function, which shadows a built-in function. Check this by removing all folders containing user-defined code from the path. Then test it again. Does it run now?
If so, re-insert the user folders and check for conflicts: FEX: UniqueFuncName.
If there are conflicts, rename the user-defined function or move them into a package.
Andrea Gargano
Andrea Gargano on 8 Jul 2018
Edited: Andrea Gargano on 8 Jul 2018
I've had the same error today. I imported some .csv file in matlab through the import data tool. I created two importfile functions with different name and used the stem function to plot it but the error message occured. I do not understand what is wrong and how to fix it.

Sign in to comment.

More Answers (3)

Felix Bernreuther
Felix Bernreuther on 18 Mar 2018
I've had the same Problem.
Solution (Linux): If you're using Linux open Matlab by typing "matlab -softwareopengl" in the shell.
Notice:
"matlab" -> no Plot is possible Error : "if ~strcmp(fig.Type,'figure')[...]"
"matlab -softwareopengl" -> plotting possible without any errors.
If there is some Expert who knows what's this about I'd like to hear his explanation.
  2 Comments
Kurt
Kurt on 25 Mar 2018
Edited: Kurt on 26 Mar 2018
% If you want to save that, try following command.
>> opengl('save','software');
mn
mn on 4 Apr 2018
I just had this problem after fresh installation of 2018a on Ubuntu 14.04, and this worked. I'd be curious to hear that expert's explanation, too.

Sign in to comment.


Sze Yu Chan
Sze Yu Chan on 8 Feb 2018
I also have the same problem using 2017b and Windows 10.
  2 Comments
Jan
Jan on 8 Feb 2018
Please post the details: Did it work before you have changed anything? If so, what has been changed? Did you exclude that a user-defined function shadows a built-in function? Remove all user-defined folders from the path and run the code again.
Did the code run successfully under a Matlab version < R2014b, when the graphics engine has been saved?
I guess, that it would take some minutes only to find the reason using the debugger. But I do not have access to your or Catalin's computer. Therefore you have to use the debugger by your own, or provide as many details as possible in the hope, that some useful information are contained also. "I have the same problem" does not allow to help you and it does not support the OP.
Sze Yu Chan
Sze Yu Chan on 9 Feb 2018
I have used MATLAB for the first time. I just installed 2017b and haven't changed anything. I tried to use debugger and had the same result as the asker's. I tried other functions that draw graphics like bar(), and still reported error. Thus I uninstall 2017b and install 2016b. Now it works.

Sign in to comment.


Steven Lord
Steven Lord on 8 Feb 2018
My suspicion is that somehow the variable x has become a matlab.graphics.GraphicsPlaceholder. The error message you posted occurs on line 11 of your code, but your plot call is on line 7 of the code you posted. What's in the four lines you left out? Did you perhaps use findobj or findall on one of those four lines, assigning the output of that call to x?

Categories

Find more on Creating, Deleting, and Querying Graphics Objects 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!