Matlab 2017b plotting error.

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

Please attach blabla.m and any data files that it reads in so we can reproduce your problem. http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
It's a simple code:
clc
x=0:0.25:4;
y=2.*exp(-x.^2)+2.*sin(0.67.*x+0.1);
g=2.2159+1.2430.*x-2.6002.*x.^2+1.7223.*x.^3-0.4683.*x.^4+0.0437.*x.^5;
e=y-g;
MSE= 1/length(x)*sum((y-g).^2);
plot(x,e);
Thx!
@Catalin: Please use the "{} Code" button to format code. This is nicer than inserting blank lines.
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

Yeah, i worked before, but first time in 2017b. I used before 2012a and i wanted an upgrade.
And yes, it's a fresh install, on Windows 8.1 Pro
As far as I understand the problem does appear for this also:
figure;
axes;
drawnow;
plot(1:10)
Correct? Then use the debugger:
dbstop if error
Does the code run now or does the error still occur? Do you see a figure already, when the error occurs? What about this case:
close('all');
plot(1:10)
If this still fails and you do not shadow any built-in functions, try to re-install Matlab.
I tried both of them and it's same error, and with debugger first error it's at
if ~strcmp(fig.Type,'figure')
And yes, i try to re-install Matlab and it's same error.
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)

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');
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

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.
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

Asked:

on 13 Jan 2018

Edited:

on 8 Jul 2018

Community Treasure Hunt

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

Start Hunting!