Python 如何设置条形图以仅使用传递到条形函数中的值?
此代码用于显示简单的条形图:Python 如何设置条形图以仅使用传递到条形函数中的值?,python,matplotlib,Python,Matplotlib,此代码用于显示简单的条形图: import matplotlib.pyplot as plt import numpy as np fig = plt.figure() x = [1] height = [8] width = 1.0 plt.bar(x, height, width, color='b' ) plt.savefig('SimpleBar.png') plt.show() 产生: 如何显示条形图的单个值?在这种情况下,请显示1而不是0.6,0.8,1.0,1.2,1.
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = [1]
height = [8]
width = 1.0
plt.bar(x, height, width, color='b' )
plt.savefig('SimpleBar.png')
plt.show()
产生:
如何显示条形图的单个值?在这种情况下,请显示1而不是0.6,0.8,1.0,1.2,1.4
尝试此操作
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = [1]
height = [8]
width = 1.0
plt.bar(x, height, width, color='b')
plt.xticks([1]) # add this line
plt.show()
这里有一些建议供您阅读更多内容。试试这个
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = [1]
height = [8]
width = 1.0
plt.bar(x, height, width, color='b')
plt.xticks([1]) # add this line
plt.show()
这是一个让你阅读更多的方法