I am sure the configuration of matplotlib
for python is correct since I have used it to plot some figures.
But today it just stop working for some reason. I tested it with really simple code like:
import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 5, 0.1) y = np.sin(x) plt.plot(x, y)
There's no error but just no figure shown up.
I am using python 2.6, Eclipse in Ubuntu
The issue actually stems from the matplotlib backend not being properly set, or from a missing dependency when compiling and installing matplotlib.
In Matplotlib, we can draw multiple graphs in a single plot in two ways. One is by using subplot() function and other by superimposition of second graph on the first i.e, all graphs will appear on the same plot.
Matplotlib is used in a terminal or scripts, plt. show() is a must. Matplotlib is used in a IPython shell or a notebook (ex: Kaggle), plt. show() is unnecessary.
In matplotlib you have two main options:
Create your plots and draw them at the end:
import matplotlib.pyplot as plt plt.plot(x, y) plt.plot(z, t) plt.show()
Create your plots and draw them as soon as they are created:
import matplotlib.pyplot as plt from matplotlib import interactive interactive(True) plt.plot(x, y) raw_input('press return to continue') plt.plot(z, t) raw_input('press return to end')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With