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

rendering issues when exception is raised before cell execution completes #10

Open
odedbd opened this issue Feb 19, 2017 · 3 comments
Open
Milestone

Comments

@odedbd
Copy link

odedbd commented Feb 19, 2017

Reposting from jupyter/notebook issue. The code cell as appears in the screen shot is:

import ipympl
import matplotlib.pyplot as plt

def plot_something():
    plt.figure()
    plt.plot([0,2],[0,2],'-')
    plt.show()

plot_something()
raise Exception

The behavior I am seeing is different for the first time I run the cell and the next times. It is also different for different level of browser zoom levels (I am using Chrome 56.0.2924.87 on Windows 8.1)-

First time that the cell is run -
The figure appears but is not fully rendered (see image)-
notebook_matplotlib_exception_ipympl
If I then resize the figure using the GUI (bottom right corner), the behavior changes based on browser zoom level-

  1. When using 100% zoom level (default), the figure is rendered too small. When in this state the zoom rectangle is drawn offset from the mouse pointer. The zooming is determined by the mouse pointer, it is just the drawing of the rectangle that is off.
  2. When using 90% zoom level (ctrl^- once), the figure is rendered to size and the zoom rectangle is working fine.

When I rerun the cell the figure is re-rendered properly without need for resizing and independent of zoom level.

@tacaswell
Copy link
Member

@odedbd Do you have a high-dpi screen?

@tacaswell tacaswell modified the milestone: 0.1 Aug 26, 2017
@odedbd
Copy link
Author

odedbd commented Sep 5, 2017

@tacaswell Nope, not HDPI

@asteppke
Copy link

I think I ran into something related to this issue. With the following code in the first cell

%matplotlib widget

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(-4, 4, 100)

fig, ax = plt.subplots(figsize=(2, 2))
ax.plot(x, x**2)

# plt.gcf().canvas.draw()

and in the second cell

raise Exception

when the notebook is started and we use "Cell->Run all" no figure is drawn with the current ipympl. When the cells are individually run after each other the figure shows up correctly. This is a bit annoying in longer notebooks where several figures are created and a typo in the last cell causes an exception and then no single figure shows up above.

By using the extra plt.gcf().canvas.draw() the figure shows up correctly even with the exception later.

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

4 participants