Matplotlib consists of three main layers which are called backend, artist, and scripting.
We are mostly dealing with the scripting layer. It is the matplotlib.pyplot interface. Scripting layer automates the process of putting everthing together. Thus, it is easier to use than the other layers.
The first example is a scatter plot. It is mainly used to visualize the relationship between two continuous variables. They provide an overview of the correlation between the variables.
We can create a scatter plot with the price and distance columns.
import matplotlib.pyplot as pltplt.figure(figsize=(10,6))
plt.scatter(x=df.Price, y=df.Landsize)
plt.xlabel("Price", fontsize=13)
plt.ylabel("Landsize", fontsize=13)
We observe a slight positive correlation between the price and land size as expected.
Another commonly used visualization type is histogram. It divides the value range of a continuous variable into discrete bins and counts the number of data points (i.e. rows) in each bin. Thus, we get an overview of the distribution.
Let’s create a histogram of the price column.
plt.figure(figsize=(10,6))
plt.hist(x=df.Price)
plt.xlabel("Price", fontsize=13)