Home >Backend Development >Python Tutorial >Why Can't I Display Matplotlib Plots Inline in My IPython Notebook?
How to Display Matplotlib Plots Inline in IPython Notebook
Question:
When using IPython notebook on macOS with specific Python and IPython versions, matplotlib graphics fail to display inline. Commands such as %matplotlib inline, %pylab inline, and ipython command line arguments do not resolve the issue. Instead, numeric figures are displayed.
Answer:
To enable inline plotting, follow these steps:
import matplotlib import numpy as np import matplotlib.pyplot as plt
Alternatively, you can set the following configuration options in your config files to always start IPython kernels in inline mode by default:
c.IPKernelApp.matplotlib = <CaselessStrEnum> Default: None Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx'] Configure matplotlib for interactive use with the default matplotlib backend.
The above is the detailed content of Why Can't I Display Matplotlib Plots Inline in My IPython Notebook?. For more information, please follow other related articles on the PHP Chinese website!