Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plt.figure() throws if not immediately followed by more plotting #13

Open
vadimkantorov opened this issue May 16, 2019 · 3 comments
Open

Comments

@vadimkantorov
Copy link

I need this to set up the report markup (ideally I'd just have <figure id="somematplotlibfigureid" /> in html and then fill them up later) and do the plotting later.

%% py
import numpy as np
import matplotlib.pyplot as plt

%% py
plt.figure('figfoo')
plt.plot(np.arange(10), np.arange(10))
plt.show()
# works

%% py
plt.figure('figbar')
# throws
# <Figure size 640x480 with 0 Axes>
# A value renderer encountered an error.
# TypeError: r.propertyIsEnumerable is not a function
#
#    in t
#    in t
#    in t
#    in t
#    in v
#    in div
#    in Styled(div)
#    in he
#    in qt
#    in div
#    in Styled(div)
#    in div
#    in Styled(div)
#    in bn
#    in jn
#    in p
#    in div
#    in div
#    in div
#    in ir
#    in p
#    in div
#    in u
#    in p
#    in lr
#    in p
#    in t
#    in p
# Please file a bug report.
@mdboom
Copy link
Contributor

mdboom commented May 17, 2019

I think it's just that the value renderer is choking on the Figure object. There's work ongoing on the Iodide side to clean up the reps and make them less likely to error out like this.

Does fig = plt.figure('figbar') instead work for you?

@vadimkantorov
Copy link
Author

@mdboom It does work. Thanks!

On the side not, is there a way to bind a matplotlib figure to an existing HTML element?

@mdboom
Copy link
Contributor

mdboom commented May 20, 2019

Not at present -- we'd have to modify things slightly to support passing on the element (or at least an element id) into the Canvas class.

@rth rth transferred this issue from pyodide/pyodide Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants