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

setting plt.rcParams['figure.figsize'] does not work. #48

Open
PrParadox opened this issue Jan 18, 2024 · 1 comment
Open

setting plt.rcParams['figure.figsize'] does not work. #48

PrParadox opened this issue Jan 18, 2024 · 1 comment

Comments

@PrParadox
Copy link

PrParadox commented Jan 18, 2024

I tried to make matplotlib responsive by doing this little trick

from js import window 
plt.rcParams['figure.figsize'] = [window.innerWidth*window.devicePixelRatio, 6] 
plt.rcParams["figure.dpi"] = window.devicePixelRatio

However, it does not work. Interestingly, even if I hardcode figsize, it still does not respect my parameters. What should be done? (the figure is interactive. i.e it has a slider)

@coatless
Copy link

I'll second this as an issue I ran across while using the matplotlib_pyodide.html5_canvas_backend module.

If I set a parameter in rcParams, then the first time I generate a graph the new dimensions are being used. However, subsequent calls with different dimensions did not change how the graph was created.

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (20,3)

That said, if I directly set a value for the figure, then the graph would disappear but the additional controls would remain.

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.ylabel('Magic Numbers')

fig = plt.figure(figsize=(10, 10))
plt.show()

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