IPython.embed(), displaying matplotlib histograms
See original GitHub issueI often use ipython to display an interactive prompt, while matplotlib histograms are shown in the background. An example of this usage is shown below.
#!/usr/bin/env python3
import matplotlib.pyplot as plt
fig,axes = plt.subplots()
axes.plot([1,2,3,4,5],[1,2,1,2,1])
plt.show(block=False)
import IPython; IPython.embed()
The intended behavior is that the histogram is displayed, and can then be interacted with while the ipython interpreter is being used. In recent versions of ipython, the matplotlib plot is displayed, but cannot be interacted with. All mouse interactions with the plot are delayed until I hit Ctrl-D to close the ipython interpreter. I have attempted to use the %matplotlib
magic method after getting into the ipython interpreter, but this only causes the plot to disappear.
Going through different versions of ipython available through pip, this issue arose between versions 4.2.1 and 5.0.0.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays, and designed to work with the broader SciPy stack. It was conceived...
Read more >IPython reference — IPython 8.7.0 documentation
pdb, the Python debugger, is a powerful interactive debugger which allows you to step through code, set breakpoints, watch variables, etc. IPython makes...
Read more >Using matplotlib in a python shell
Call figure() and a figure window pops up, call plot() and your data appears in ... There has been a lot of recent...
Read more >matplotlib.plot in embedded IPython immediately shows plot ...
I normally import matplotlib in IPython this way: %matplotlib inline import matplotlib.pyplot as plt ax, fig = plt.subplots() plt.plot([[1 ...
Read more >Plot Histograms Using Pandas: hist() Example - Mode Analytics
This recipe will show you how to go about creating a histogram using Python. Specifically, you'll be using pandas hist() method, which is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The code below works for me. You need to enable mpl integration before drawing the plot, because it calls
plt.switch_backend()
, which closes any open figures.any suggestions on the above issue?