Bivariate plots in pandas
Comparing multiple variables simultaneously is also another useful way to understand your data. When you have two continuous variables, a scatter plot is usually used.
# Scatter plot
df.plot(x='x_column', y='y_column', kind='scatter')
plt.show()
You can use a boxplot to compare one continuous and one categorical variable. However, you will be using the .boxplot()
method instead of the .plot()
method.
# Boxplot
df.boxplot(column='y_column', by='x_axis')
plt.show()
This exercise is part of the course
Python for R Users
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
import matplotlib.pyplot as plt
# Scatter plot between the tip and total_bill
tips.plot(____, ____, ____)
plt.show()