ipykernel icon indicating copy to clipboard operation
ipykernel copied to clipboard

Fix matplotlib's param not updated in the first cell

Open fehiepsi opened this issue 6 years ago • 0 comments

Background

#264 is made to remove the necessity of plt.show(). However, it causes various problems as reported at #295, https://github.com/jupyter/notebook/issues/3385, https://github.com/ipython/ipython/issues/11098. In addition, even with #264, we need to call plt.show() in the first cell. I think that somehow, the line matplotlib.pyplot.switch_backend(backend) causes problem. Docs of switch_backend method says that "Switching to an interactive backend is possible only if no event loop for another interactive backend has started. Switching to and from non-interactive backends is always possible." As I understand, we should not call switch_backend two times in the same cell (even if we have the same backend).

This PR tries to solve above problems by not calling activate_matplotlib(backend) but only setting matplotlib.interactive(True) in _enable_matplotlib_integration() method.

The result works well in my system. RCparams are updated in the first cell. In addition, we don't need to call plt.show in the first cell.

fehiepsi avatar Jan 23 '19 09:01 fehiepsi