值不显示在条形图中

时间:2021-06-13 21:42:11

标签: python matplotlib

我有两个列表,我想使用 matplotlib 在基本条形图中显示它们,但值不显示我该如何解决这个问题?

Axis x

Axis y

Graphic

import matplotlib.pyplot as plt
def factorial(a):
    return 1 if (a == 1 or a == 0) else a * factorial(a - 1);
def combination(b,r):
    co=factorial(b)/(factorial(r)*factorial(b-r))
    return co
yaxis=[]
for i in range (170,201):
    x=0
    x=combination(200,i)*((0.2)**(200-i))*((0.8)**i)
    yaxis.append(x)
xaxis=[]
for i in range(170,201):
    y=0
    y=i
    xaxis.append(y)
plt.bar(xaxis,yaxis)
plt.show()


xaxis
[170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]
yaxis
[0.014744981392768381, 0.010347355363346232, 0.006978448965977692, 0.004517839793002899, 0.0028041764232431786, 0.0016664819886702317, 0.0009468647662899046, 0.0005135537715470668, 0.0002654322864175851, 0.0001304918503058519, 6.0896196809397556e-05, 2.691544610360113e-05, 1.1239417054251021e-05, 4.422065726262698e-06, 1.6342416814449098e-06, 5.653592843917524e-07, 1.8237396270701693e-07, 5.4614662628839286e-08, 1.510618328031725e-08, 3.836490991826603e-09, 8.884505454756346e-10, 1.8606294146086586e-10, 3.488680152391235e-11, 5.784340149042463e-12, 8.34853217387572e-13, 1.0275116521693192e-13, 1.048481277723795e-14, 8.515583981513058e-16, 5.1609599887957925e-17, 2.0747577844405194e-18, 4.149515568881039e-20]

0 个答案:

没有答案