python bubble plot 1

python bubble plot

import matplotlib.pyplot as plt
# scatter plot with scatter() function
# bubble size with "s"
# df dataframe contain columns X, Y, Z variables values
plt.scatter('X', 'Y', s='Z', data=df)
plt.xlabel("X", size=16)
plt.ylabel("y", size=16)
plt.title("Bubble Plot", size=18)

Here is what the above code is Doing:
1. plt.scatter() is a function that takes in x-axis data, y-axis data, and size data.
2. The x-axis data is the column ‘X’ from the df dataframe.
3. The y-axis data is the column ‘Y’ from the df dataframe.
4. The size data is the column ‘Z’ from the df dataframe.
5. plt.xlabel() is a function that takes in the label for the x-axis.
6. plt.ylabel() is a function that takes in the label for the y-axis.
7. plt.title() is a function that takes in a string value for the plot title.

Similar Posts