Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Last active November 19, 2019 18:34
Show Gist options
  • Save thomasaarholt/9841ce2424bc40e3165142764e960150 to your computer and use it in GitHub Desktop.
Save thomasaarholt/9841ce2424bc40e3165142764e960150 to your computer and use it in GitHub Desktop.
Temporary workaround for traditional mpl figure behaviour with the ipympl widget backend
import matplotlib.pyplot as plt
def figure(figsize=None):
'Temporary workaround for traditional figure behaviour with the ipympl widget backend'
fig = plt.figure()
if figsize:
w, h = figsize
else:
w, h = plt.rcParams['figure.figsize']
fig.canvas.layout.height = str(h) + 'in'
fig.canvas.layout.width = str(w) + 'in'
return fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment