Conteúdo do Curso
Visualization in Python with matplotlib
Visualization in Python with matplotlib
Creating an Empty Plot
Welcome to the course! In this course, we will learn the matplotlib
library, probably, one of the most popular visualization tools for Python. Within the course, we will focus on pyplot
- state-based interface to matplotlib
.
Note
Common practice is using the
plt
alias formatplotlib.pyplot
. This is not compulsory, but widely used by Python community, so I recommend you to follow this rule.
The basic concept of building plots in matplotlib
is using two objects: Figure as a space for building your graph and Axes - an area where points can be specified (usually in terms of x-y coordinates, but also in a 3D plot, for example, and so on).
To create both Figure and Axes objects, you can use the .subplots()
function from matplotlib.pyplot
using multiple assignment (we need to create two variables: for Figure
and Axes
objects). That's why using an alias is a good practice. Finally, after assigning Figure
and Axes
objects to certain variables, we can initialize an empty plot by applying the .plot()
function to the Axes
object. Finally, we use plt.show()
to display the plot.
# Import the library import matplotlib.pyplot as plt # Create Figure and Axes objects fig, ax = plt.subplots() # Initialize an empty plot ax.plot() # Display the plot plt.show()
Obrigado pelo seu feedback!