pyplot second y axis

Solutions on MaxInterview for pyplot second y axis by the best coders in the world

showing results for - "pyplot second y axis"
Frieda
19 Aug 2017
1import numpy as np
2import matplotlib.pyplot as plt
3
4# Create some mock data
5t = np.arange(0.01, 10.0, 0.01)
6data1 = np.exp(t)
7data2 = np.sin(2 * np.pi * t)
8
9fig, ax1 = plt.subplots()
10
11color = 'tab:red'
12ax1.set_xlabel('time (s)')
13ax1.set_ylabel('exp', color=color)
14ax1.plot(t, data1, color=color)
15ax1.tick_params(axis='y', labelcolor=color)
16
17ax2 = ax1.twinx()  # instantiate a second axes that shares the same x-axis
18
19color = 'tab:blue'
20ax2.set_ylabel('sin', color=color)  # we already handled the x-label with ax1
21ax2.plot(t, data2, color=color)
22ax2.tick_params(axis='y', labelcolor=color)
23
24fig.tight_layout()  # otherwise the right y-label is slightly clipped
25plt.show()
26
Ignacio
02 Apr 2017
1import numpy as np
2import matplotlib.pyplot as plt
3x = np.arange(0, 10, 0.1)
4y1 = 0.05 * x**2
5y2 = -1 *y1
6
7fig, ax1 = plt.subplots()
8
9ax2 = ax1.twinx()
10ax1.plot(x, y1, 'g-')
11ax2.plot(x, y2, 'b-')
12
13ax1.set_xlabel('X data')
14ax1.set_ylabel('Y1 data', color='g')
15ax2.set_ylabel('Y2 data', color='b')
16
17plt.show()
queries leading to this page
plot with two y axis pythonadd secondary y axis pythonwhy my plot have double x axis pythonhow to add a secondary azis pythonpyplot second y axis labeldsecondary y axis pltadd secondary axis pythonmatplotlib double y axismatplotlib plot with two different y axishow to plot 2 axis matplotlibpython two y axismatplotlib second x axis below add second y axis matplotlibdouble y axis pythonsecond axis matplotlibsecond y axis matplotlibmatplotlib dual axis linesdouble y axis matplotlibplotting two y axis on top of the same plot pythonggplot second y axis scaleplot multiple axis matplotlibadd already plotted axes on another axes pythonmatplotlib plot twinmatplotlib plot on second y axissecondary axis pyplotplot second y axis matplotlibmatplotlib two plots different y axisplot two axes pythonuse second y axis pltcombine top two plots in matplotlibe 2 2a 2 subplotsmatplotlib separate y labelssecond y scale matplotlibmatplotlib second y axisplt python how to create 2 axis plothow to make 2 plot in 1 with two y labels matplotlibmatplotlib line different scalesdifferent scale in matplotlibsecond y axis matplitlubhow to plot with two y axis in pythonpyplot two plots two y axispython plot double y axispython plot different left and right y axismake a second y axis wth clone x matplotlibadd a second axis in pythonplt plot 2 y axisplot multiple y axis pythonsecondary axis label matplotlibplot two y axis pythonhow to plot on secondary axis in python plotname secondary axis in pythonmatplotlib right axismatplotlib 2 y axisplot 2 axis pythontwo scales matplotlibonly display two axis matplotlibdifferent scale for y ax in matplotlibpython matplotlib add second y axismatplotlib two axis single plotmultiple plot with different scales in matplotlibpython plot two lines different scalespython plot same axis examplematplotlib two y axesadd another axis pythonmatplotlib two axeshow to plot graphs with different scale in pythonmatplotlib with 2 y axestwo axis graph with matplotlibtwo different y axes matplotlib 23plot multiple lines with different scales matplotlibset second y axis matplotlibdouble axis mathplotlibtwo y axis plt pythonmatplotlib diffrante scale axismatplotlib multiple axesadd second y axis to plot matplotlibplot two graphs with different sacle pythonmatplotlib double y axis with mutiple eachpython graphing two axis on same scalehow to add secondary axis in pythonplot matplotlib graph with differnt axis valuessecondary y axis matplotlibdual axis chart pythonhow to plot charts for two axis in matplotlibplot on secondary axis matplotlib2 y axis plot matplotlibpython dual axis plotplotyy pythontwo y axis matplotlibplot right away pyplotdual axis plot in pythonmatplotlib multiple y axiplt plot two y axisplot multiple y axis matplotlibplt 2 axesmatplotlib plot two different y axisadd y axus matplotlibhow to get two y axis in pythonplot two x axis matplotlibsecond axis matplotlib y axismultiple x axis matplotlibmatplotlib pyplot plot multiple axesdrawing a graphs in python with different scalematplotlib pyplot set second y axis labelpython matplotlib second y axismatplotlib with two axismatplotlib 2 axisplot second axis pythontwo axis plot matplotlibhow to add a secondary axis in python matplotpython plot 2 axishow to plot left and right y axis with x axis in pythonmatplotlib dual axisdrawing secondary axis in matplotlibplot second y axis pythonax2 3d ax1 twinx 28 29varying scale for the y axis in matplotlibhow to create a graph with two y axis in matplotlib pythonplot secondary y axis matplotlibmatplotlib two plots with different y axisadd secondary x scale on a plot in pythonpython second y axissecondary y label matplotlibplot double y axis pythonax2 in pythonplot 2 y axis pythonmatplotlib graph with 2 y axismatlotlib different axispyplot multiple axespyplot dual axistwo axis matplotlibpython plot with two y axispython 2 line plots with different scalesplot graph with 2 y axis matplotlibmatplotlib plot different scalesplt plot secondary y axismatplotlib multiple y axis labelplot two different scales matplotlibmatplotlib different y axismatplotlib dual y axis2 y axis in matplotlibplot two scales on x axis matplotlib pyplotpyplot add second y axismatplotlib secobndary y axismatplotlib plt plot make second y axisdifferent axis plotmatplotlib multiple y axespyplot multiple y axeshow to plot two y axis in pythonmatplotlib multiple y axisdrawing secondary axis in scatter plots in matplotlibdataframe plot 2 y axismatplotlib making a plot with 2 y axispython plot on secondary axisplotting extra axis on right matplotlibsecondary y axis in axespython matplotlib how to make 2 axis graphhow to plot wo plots with different axis pythonmatplotlib add second y axismatplotlib two y axis labelpython matplotlib plot multiple x and y axiscreate two scales on x axis matplotlib python2 axis on same graph matplotmaplotlib plot graph with different axis sizeshow to name y axis with two axis in pythonmatplotlib secondary y axispyplot second y axisplot on different axis pythonmatplotlib python plotting two y axis with different scale with same x axismatplotlib how to put multiple y axis plotspython matplotlib plot multiple x ypyplot two y axesmatplotlib 2 ysecond y axis plotly pythonpython plot two y axispython plot 2 y axispython matplotlib second y axis labelmatplot lib scatter plot in different axissecond y axis matplotlibplt second axisplt plot two axis ymatplotlib make scales of two plots equaltwo y axis in pythonmatplotlib 2 axis one figurematplotlib double yaxis plotpython matplotlib two y axispython dual y axispython plot with two y axis bokaepython plot two graphs with different scalematplotlib line differente scalersmatplotlib double axis plotmatplotlib plot two lines with different y axissecondary axis pythonpython plot two y axis single x axis with offest2nd y label on right matplotlibpython double y axispyplot second y axis