question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"AttributeError: 'dict' object has no attribute 'figure'"

See original GitHub issue

When I run the example in the tutorial, (https://nbviewer.jupyter.org/github/SheffieldML/notebook/blob/master/GPy/basic_gp.ipynb), I get the error below. My matplotlib version is 3.3.4

# test
X1 = np.random.uniform(-3.,3.,(20,1))
Y1 = np.sin(X1) + np.random.randn(20,1)*0.05
kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)
m1 = GPy.models.GPRegression(X1,Y1,kernel)
fig = m1.plot()
GPy.plotting.show(fig, filename='basic_gp_regression_notebook')

> AttributeError                            Traceback (most recent call last)
> <ipython-input-61-e67b8a20cbc2> in <module>
>       1 fig = m1.plot()
> ----> 2 GPy.plotting.show(fig, filename='basic_gp_regression_notebook')
> 
> ~\Anaconda3\envs\ml\lib\site-packages\GPy\plotting\__init__.py in show(figure, **kwargs)
>     148     for showing/drawing a figure.
>     149     """
> --> 150     return plotting_library().show_canvas(figure, **kwargs)
>     151 
>     152 
> 
> ~\Anaconda3\envs\ml\lib\site-packages\GPy\plotting\matplot_dep\plot_definitions.py in show_canvas(self, ax, **kwargs)
>      94 
>      95     def show_canvas(self, ax, **kwargs):
> ```
> ---> 96         ax.figure.canvas.draw()
>      97         return ax.figure
>      98 
> 
> AttributeError: 'dict' object has no attribute 'figure'

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jwwtccommented, Jun 18, 2022

Hello.

Has this issue been resolved since it opened? The same error came up to me.

Thanks!

0reactions
Xiangke-Lancommented, May 29, 2022

Thx, I have also fixed it as following:

import matplotlib.pyplot as plt

fig = m.plot(title='basic_gp_regression_notebook')
plt.show()
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - AttributeError: 'dict' object has no attribute 'predictors'
The AttributeError is an exception thrown when an object does not have the attribute you tried to access. The class dict does not...
Read more >
AttributeError: 'dict' object has no attribute 'shape' #364 - GitHub
Hi! It looks like either 'nest_utils.get_outer_shape' or 'common.replicate' might have a bug on batched dictionary actions.
Read more >
AttributeError: 'dict' object has no attribute 'value' - Treehouse
To get the value associated with a key, use the key as an index with square brackets (" student['topic'] ").
Read more >
python tutorial: AttributeError: 'dict' object has no attribute 'value'
python tutorial: #codefix # python #python_tutorialAttributeError: ' dict ' object has no attribute 'value': In this video i have shared why ...
Read more >
'dict' object has no attribute 'shape' - Report bugs - Edge Impulse
'dict' object has no attribute 'shape' ... My Neural Network gives this error while training it. ... @dansitu Looks like a bug. Any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found