Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

object oriented method of matplotlib in python

# OO method basics
fig, ax = plt.subplots(figsize=(10,6))

# Plot the data,and save plot in a variable for customization of plot
scatter = ax.scatter(x=over_50["age"],
                     y=over_50["chol"],
                     c=over_50["target"])

# Customize the plot
ax.set(title="Heart Disease and Cholesterol Levels",
       xlabel="Age",
       ylabel="Cholesterol")

# Add a legend, here *unpacks every value,so must be used
ax.legend(*scatter.legend_elements(),title="Target");
Source by matplotlib.org #
 
PREVIOUS NEXT
Tagged: #object #oriented #method #matplotlib #python
ADD COMMENT
Topic
Name
3+6 =