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

Plots not showing in Jupyter Notebook #14534

Closed
tushar-mehndiratta-alt opened this issue Jun 12, 2019 · 5 comments
Closed

Plots not showing in Jupyter Notebook #14534

tushar-mehndiratta-alt opened this issue Jun 12, 2019 · 5 comments

Comments

@tushar-mehndiratta-alt
Copy link

When I try to run plt.show() code for plotting a graph, then only the image size appears but not the plot.

Code for reproduction

import matplotlib.pyplot as plt
slices_hours = [4, 8]
activities = ['Sleep', 'Work']
colors = ['r', 'g']
plt.pie(slices_hours, labels=activities, colors=colors, startangle=90, autopct='%.1f%%')
plt.show()

Actual outcome

<Figure size 640x480 with 1 Axes>

Actual Code with Output

image

Expected outcome

image

Matplotlib version

  • Operating system: Windows 10 Home, Version: 1809, OS Build: 17763.529
  • Matplotlib version: 3.1.0
  • Matplotlib backend (print(matplotlib.get_backend())):
    module://ipykernel.pylab.backend_inline
  • Python version: 3.7.3
  • Jupyter version (if applicable): 4.4.0
  • Other libraries: pip list
    Package Version

attrs 19.1.0
backcall 0.1.0
bleach 3.1.0
colorama 0.4.1
cycler 0.10.0
decorator 4.4.0
defusedxml 0.6.0
entrypoints 0.3
ipykernel 5.1.1
ipython 7.5.0
ipython-genutils 0.2.0
jedi 0.13.3
Jinja2 2.10.1
jsonschema 3.0.1
jupyter-client 5.2.4
jupyter-core 4.4.0
jupyterthemes 0.20.0
kiwisolver 1.1.0
lesscpy 0.13.0
MarkupSafe 1.1.1
matplotlib 3.1.0
mistune 0.8.4
nbconvert 5.5.0
nbformat 4.4.0
notebook 5.7.8
numpy 1.16.4
pandocfilters 1.4.2
parso 0.4.0
pickleshare 0.7.5
pip 19.1.1
ply 3.11
prometheus-client 0.7.0
prompt-toolkit 2.0.9
Pygments 2.4.2
pyparsing 2.4.0
pyrsistent 0.15.2
python-dateutil 2.8.0
pywinpty 0.5.5
pyzmq 18.0.1
Send2Trash 1.5.0
setuptools 40.8.0
six 1.12.0
terminado 0.8.2
testpath 0.4.2
tornado 6.0.2
traitlets 4.3.2
wcwidth 0.1.7
webencodings 0.5.1

@ImportanceOfBeingErnest
Copy link
Member

Many people report on the "inline" backend selected by default, but that is not my experience. Possibly some distributions add additional code that selects/activates the backend. To be on the safe side one can do it manually, e.g. putting one of the following in the first line of the notebook

  • %matplotlib inline - Figures are shown as static png images (optionally svg if configured)
  • %matplotlib notebook or %matplotlib nbagg - Interactive Figures inside the notebook
  • %matplotlib widgets - - Interactive Figures inside the notebook (requires jupyter-matplotlib to be installed)
  • %matplotlib tk or %matplotlib qt etc. - GUI windows show the figure externally to the notebook with the given interactive backend

@tushar-mehndiratta-alt
Copy link
Author

@ImportanceOfBeingErnest Thanks it works for now.

@Lotfey
Copy link

Lotfey commented Apr 30, 2020

this link would work for you as it did for me, good luck
https://github.com/matplotlib/ipympl

@1014violin
Copy link

Thank you!!! This worked for me too!

@1014violin
Copy link

Also it is helpful to restart the kernel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants