Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib object oriented

fig, ax1 = plt.subplots()

ax1.set_ylabel("distance (m)")
ax1.set_xlabel("time")
ax1.plot(time, distance, "blue")

ax2 = ax1.twinx() # create another y-axis sharing a common x-axis


ax2.set_ylabel("velocity (m/s)")
ax2.set_xlabel("time")
ax2.plot(time, velocity, "green")

fig.set_size_inches(7,5)
fig.set_dpi(100)

plt.show()
Comment

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");
Comment

PREVIOUS NEXT
Code Example
Python :: pygame moving shape 
Python :: decision tree best param 
Python :: sklearn grid search cross validation show progress 
Python :: install nsml python 
Python :: how to plot a single cluster 
Python :: replace() python 
Python :: ndarray python 
Python :: enumerate() 
Python :: MNIST model 
Python :: unlimited arguments 
Python :: pd df replace 
Python :: convert PIL RGB to opencv BRG 
Python :: 3d plot 
Python :: groupby in python 
Python :: plotly ylog 
Python :: Python NumPy squeeze function Example 
Python :: godot get scenes from folder 
Python :: create a thumbnail from video python 
Python :: python print main arguments 
Python :: tar dataset 
Python :: check how many days old file is python 
Python :: how to add to beginning of linked list python 
Python :: pyqt popup yes no 
Python :: python tabulate without index 
Python :: convert math equation from string to int 
Python :: add text to jpg python 
Python :: bst deleting in python 
Python :: NumPy left_shift Syntax 
Python :: twitter scraping python 
Python :: plt grid linestyles options 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =