我有4个列表-yr_list,income_list,expense_list和profit_list。
我想在y轴上显示yr_list,在y轴上显示入帐单为条形图,在y轴上显示出支出单的条形图,在辅助y轴中显示为折线的利润表。我怎么做?
[2013, 2014, 2015, 2016, 2017, 2018]
[3174507.7278688527, 4666571.258098361, 4757771.147540984, 3347104.209836066, 3475079.6604590164, 3282371.708852459]
[2957117.5807213113, 4133987.196196721, 4617619.47947541, 3218228.637639344, 3402567.9462295077, 3226548.6240000003]
[217390.14714754096, 532584.0619016397, 140151.66806557373, 128875.57219672124, 72511.7142295087, 55823.084852459004]
yr_list = [2013, 2014, 2015, 2016, 2017, 2018]
income_list= [3174507.7278688527, 4666571.258098361, 4757771.147540984, 3347104.209836066, 3475079.6604590164, 3282371.708852459]
expense_list = [2957117.5807213113, 4133987.196196721, 4617619.47947541, 3218228.637639344, 3402567.9462295077, 3226548.6240000003]
profit_list = [217390.14714754096, 532584.0619016397, 140151.66806557373, 128875.57219672124, 72511.7142295087, 55823.084852459004]
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure()
# To get the axis of the figure
ax = fig.add_axes([0,0,1,1])
# Add bar plot
ax.bar(yr_list, income_list, color = 'b', width = 0.25, label='Income')
# Add the second bar plot with a small shift
ax.bar([yr + 0.25 for yr in yr_list], expense_list, color = 'g', width = 0.25, label='Expense')
# Adds line plot
ax.plot(yr_list , profit_list , color = 'y', label='Profit')
plt.legend()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句