我在尝试用Python绘制大学作业中的图形时遇到了一些麻烦。我想在 x 轴上绘制从最大范围到最小范围的图形。我的代码是下一个:
import numpy as np
import matplotlib.pyplot as plt
# function that plots the cummulative histogram
def plotFunction( array , numberBins ):
# Array of elements that will be plotted on log scale
elements = array
# evaluate the histogram
values, base = np.histogram(elements, bins= len( numberBins ) )
#evaluate the cumulative
cumulative = np.cumsum(values)
# plot the cumulative function
plt.plot( cumulative , base[:-1] , c='blue')
plt.show()
我想以相反的方式设置轴,从 200 到 20。
最佳答案
使用坐标区的 xlim 函数或 set_xlim 方法:
plt.xlim(200, 20)
关于python - 如何在Python中绘制从最大范围到最小范围的图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22461307/