Which is the recommended way to plot: matplotlib or pylab?


I can plot in Python using either:

import matplotlib


import pylab

Both of these use matplotlib.

Which is recommend as the correct method to plot? Why?


From the official documentation, as shown below, the recommendation is to use matplotlib.pyplot. This is not an opinion.

The documentation at Matplotlib, pyplot and pylab: how are they related?, which also describes the difference between pyglot and pylab, states: "Although many examples use pylab, it is no longer recommended.".

2021-05-06 Edit:

Since heavily importing into the global namespace may result in unexpected behavior, the use of pylab is strongly discouraged. Use matplotlib.pyplot instead.

Answered By – Apostolos

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published