Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

plt python two axis

# create figure and axis objects with subplots()
fig,ax = plt.subplots()
# make a plot
ax.plot(gapminder_us.year, gapminder_us.lifeExp, color="red", marker="o")
# set x-axis label
ax.set_xlabel("year",fontsize=14)a
# set y-axis label
ax.set_ylabel("lifeExp",color="red",fontsize=14)
# twin object for two different y-axis on the sample plot
ax2=ax.twinx()
# make a plot with different y-axis using second axis object
ax2.plot(gapminder_us.year, gapminder_us["gdpPercap"],color="blue",marker="o")
ax2.set_ylabel("gdpPercap",color="blue",fontsize=14)
plt.show()
# save the plot as a file
fig.savefig('two_different_y_axis_for_single_python_plot_with_twinx.jpg',
            format='jpeg',
            dpi=100,
            bbox_inches='tight')
Comment

PREVIOUS NEXT
Code Example
Python :: django login 
Python :: matrix multiplication nupy 
Python :: how to count number of records in json 
Python :: staticmethod python 
Python :: django bulk update 
Python :: sort dict of dicts by key 
Python :: Python program to find N largest elements from a list 
Python :: Your WhiteNoise configuration is incompatible with WhiteNoise v4.0 
Python :: python __lt__ magic method 
Python :: append 1 colimn in pandas df 
Python :: xlsb file in pandas 
Python :: how to use django-rest-framework-datatables 
Python :: hide tkinter window 
Python :: flask send email gmail 
Python :: dash log scale 
Python :: how to convert response to beautifulsoup object 
Python :: dataframe print column 
Python :: Converting objects into integers in python 
Python :: float64 python 
Python :: python A string float numeral into integer 
Python :: how to make a timer using python 
Python :: while loop in python 
Python :: seaborn modificar o tamanho dos graficos 
Python :: pip change python version 
Python :: install python macos catalina 
Python :: inpuit inf terfminal ppython 
Python :: matplotlib default style 
Python :: create_polygon tkinter 
Python :: python glob subdirectories 
Python :: pandas aggregate dataframe 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =