matplotlib-pyodide
matplotlib-pyodide copied to clipboard
setting plt.rcParams['figure.figsize'] does not work.
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)
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()