Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

second y axis matplotlib

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10, 0.1)
y1 = 0.05 * x**2
y2 = -1 *y1

fig, ax1 = plt.subplots()

ax2 = ax1.twinx()
ax1.plot(x, y1, 'g-')
ax2.plot(x, y2, 'b-')

ax1.set_xlabel('X data')
ax1.set_ylabel('Y1 data', color='g')
ax2.set_ylabel('Y2 data', color='b')

plt.show()
Comment

plot second y axis matplotlib

#We create a secondary y-axis for the definded column
df.plot(secondary_y='name_of_column')
plt.show()
Comment

matplotlib plot in second axis

fig,ax = plt.subplots()
ax.plot(y1)
ax2=ax.twinx()
ax2.plot(y2)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: keras tuner 
Python :: how to print time python 
Python :: python pywhatkit 
Python :: load a Dictionary from File in Python Using the Load Function of the pickle Module 
Python :: concatenate directories python 
Python :: Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming 
Python :: renaming column in dataframe pandas 
Python :: python numpy array replace nan with string 
Python :: python get string from decimal 
Python :: python date iso 8601 
Python :: playsound python 
Python :: pycairo 
Python :: sorted vs sort python 
Python :: how to get input from list in python 
Python :: get python path 
Python :: internal server error 500 python flask 
Python :: python strptime format codes 
Python :: remove element from list python 
Python :: plotly hide color bar 
Python :: Using Variables with Multiple Instances of a Python Class 
Python :: get last element of a list python 
Python :: python add element to array 
Python :: how to run bash script in python 
Python :: Replace the string with NAN value 
Python :: increase a date in python 
Python :: how to use the random module in python 
Python :: calculate age python 
Python :: get the name of a file using os 
Python :: select random value from list python 
Python :: df col to dict 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =