python matplotlib two y axis

Solutions on MaxInterview for python matplotlib two y axis by the best coders in the world

showing results for - "python matplotlib two y axis"
Tina
15 Apr 2018
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
Juan José
25 Jan 2019
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
matplotlib multiple y axesplot multiple y axis pythonmatplotlib double yaxis plothow to plot on secondary axis in python plotmatplotlib how to put multiple y axis plotsmatplotlib plot different scalesmatplotlib line different scalestwo axis graph with matplotlibadd secondary axis pythonsecond y scale matplotlibpython plot two y axistwo y axis matplotlibpython matplotlib plot multiple x ymultiple axis matplotlibpython plot two graphs with different scaleplot secondary y axis matplotlibmaplotlib plot graph with different axis sizesmatplotlib two axesmatplotlib plt plot make second y axisplt plot secondary y axistwo y axis in pythonpyplot two y axesggplot second y axis scalehow to add secondary axis in pythonpython plot 2 axismatplotlib python plotting two y axis with different scale with same x axisplot two scales on x axis matplotlib pyplotmatplotlib 2 axisax2 3d ax1 twinx 28 29matplotlib plot two lines with different y axissecond y axis matplotlibtwo axis plot matplotlibpython plot on secondary axispython matplotlib plot multiple x and y axisadd secondary y axis pythonwhy my plot have double x axis pythonpython plot two y axis single x axis with offest2 axes matplotlibmatplotlib making a plot with 2 y axis2 y axis plot matplotlibmatplotlib multiple axesdual axis plot in pythonplt plot two axis yadd a second axis in pythonmatplotlib different y axisplt plot 2 y axisplt python how to create 2 axis plothow to add a secondary azis pythonhow to plot graphs with different scale in pythonmatplotlib 2 y axisplot matplotlib graph with differnt axis valuesplot 2 axis pythonpyplot two different y axistwo axis matplotlibmatplotlib with 2 y axesmatplotlib two y axis labelhow to create a graph with two y axis in matplotlib python2nd y axis matplotlibmatplotlib second y axis without axismatplotlib double y axismatplotlib make scales of two plots equalplt two y axissecondary y label matplotlibplt 2 axesplot two axes pythonmatplotlib plot with two y axeshow to add a secondary axis in python matplotpyplot add second y axisdrawing a graphs in python with different scaledouble axis mathplotlibplot multiple lines with different scales matplotlibplot two y axis pythonadd secondary x scale on a plot in pythonhow to get two y axis in pythondouble y axis pythonpython plot 2 y axismatplotlib with two y axispython matplotlib second y axis labelmatplotlib multiple y axis labelpython plot with two y axispython 2 line plots with different scalesadd second y axis to plot matplotlibpython second y axisplot two y axis pyplotadd another axis pythonpython matplotlib two y axisplt second axishow to plot left and right y axis with x axis in pythonpython double y axisplot graph with 2 y axis matplotlib2nd y label on right matplotlibmatlotlib different axisdataframe plot 2 y axissecond y axis label matplotlibmatplotlib double y axis with mutiple eachsecond axis matplotlibmatplotlib multiple y axismatplotlib add second y axisplot second y axis matplotlibhow to have two different y scales for graphs matplotlibhow to plot charts for two axis in matplotlibhow to make 2 plot in 1 with two y labels matplotlibax2 in pythonmatplotlib multiple y axiadd second y axis matplotlibadd already plotted axes on another axes pythonmatplot lib scatter plot in different axisplot second axis pythonadd y axus matplotlibdifferent scale in matplotlibplot second y axis pythonplotting multiple y axis in pythonsecondary y axis pltname secondary axis in pythonmultiple x axis matplotlibpython matplotlib how to make 2 axis graphpython matplotlib second y axishow to make second axis matplotlibpython matplotlib add second y axisplot with two y axis pythonmatplotlib dual y axishow to plot two y axis in pythonpyplot multiple y axesmatplotlib pyplot set second y axis labelmatplotlib two categories on the x axismatplot lib with two axis pandasdifferent scale for y ax in matplotlib2 axis plot matplotlibdouble y axis matplotlibtwo axes matplotlibpython graphing two axis on same scalematplotlib two axis single plotpython plot same axis examplemultiple plot with different scales in matplotlibmatplotlib right axispython dual y axismatplotlib 2 axis one figurepyplot two plots two y axismatplotlib plot twinsecond axis matplotlib y axisplot multiple y axis matplotlibmatplotlib with two axismatplotlib second y axisplotting two y axis on top of the same plot pythonplotyy pythonmatplotlib how to plot an x value with multiple yssecond y axis plotly pythonplot double y axis pythonmatplotlib graph with 2 y axispython dual axis plotsecondary y axis matplotliby axis multiply matplotlibpyplot second y axishow to name y axis with two axis in pythonplt second y axistwo y axis matplotlibmatplotlib dual axismatplotlib plot with two different y axismatplotlib two y axesmatplotlib 2 ysecond y axis in pythonpyplot second y axis labeldpython plot multiple x and y axismatplotlib dual axis linespython plot two lines different scalesplot on different axis pythonmatplotlib two plots different y axisplotting extra axis on right matplotlibmatplotlib plot two different y axissecondary axis label matplotlibhow to plot with two y axis in pythontwo scales matplotlibplot two graphs with different sacle pythonmatplotlib pyplot plot multiple axessecond y axis matplotlibplot 2 y axis pythondual axis chart pythonplt add second axismatplotlib two plots with different y axismatplotlib double axis plotmultiple y axis matplotlibmatplotlib secobndary y axisplot on secondary axis matplotlibpyplot 2 y axispython two y axisset second y axis matplotlibuse second y axis plttwo y axis plt pythonpyplot dual axismatplotlib line differente scalers2 y axis in matplotlibhow to plot 2 axis matplotlibcreate two scales on x axis matplotlib pythonhow to plot wo plots with different axis pythonpyplot plot with 2 y axesmatplotlib plot on second y axistwo y axis pythonsecondary axis pythonsecondary y axis in axespython plot different left and right y axispython plot double y axismatplotlib diffrante scale axismatplotlib second x axis below python plot with two y axis bokaematplotlib separate y labelsdifferent axis plotplot two x axis matplotlibdrawing secondary axis in scatter plots in matplotlibonly display two axis matplotlibdrawing secondary axis in matplotlibpyplot multiple axesplot right away pyplotcombine top two plots in matplotlibe 2 2a 2 subplotsplot multiple axis matplotlibmake a second y axis wth clone x matplotlibsecond y axis matplitlubvarying scale for the y axis in matplotlibplt plot two y axisplot two different scales matplotlibsecondary axis pyplotmatplotlib secondary y axis2 axis on same graph matplottwo different y axes matplotlib 23python matplotlib two y axis