- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Which is the recommended way to plot â€“ matplotlib or pylab?
pylab is a module that imports matplotlib.pyplot (for plotting) and numpy (for mathematics and working with arrays) in a single namespace.
Although many examples use pylab, it is no longer recommended. For non-interactive plotting, it is suggested to use pyplot to create the figures and then the OO interface for plotting.
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2, 100) plt.plot(x, x, label='linear') plt.plot(x, x**2, label='quadratic') plt.plot(x, x**3, label='cubic') plt.xlabel('x label') plt.ylabel('y label') plt.title("Simple Plot") plt.legend() plt.show()
- Related Articles
- How do I plot a spectrogram the same way that pylab's specgram() does? (Matplotlib)
- Recommended way to embed PDF in HTML?
- How to plot 1D data at a given Y-value with PyLab using Matplotlib?
- How to use different markers for different points in a Pylab scatter plot(Matplotlib)?
- How to pause a pylab figure until a key is pressed or mouse is clicked? (Matplotlib)
- Best way to plot an angle between two lines in Matplotlib
- How to check that pylab backend of Matplotlib runs inline?
- How to print the Y-axis label horizontally in a Matplotlib/Pylab chart?
- How to plot half or quarter polar plots in Matplotlib?
- Draw axis lines or the origin for Matplotlib contour plot.
- What is pylab?
- What is the difference between drawing plots using plot, axes or figure in matplotlib?
- How to plot true/false or active/deactive data in Matplotlib?
- How to plot a non-square Seaborn jointplot or JointGrid? (Matplotlib)
- What is the preferred way to set Matplotlib figure/axes properties?