python - 如何在Python中绘制从最大范围到最小范围的图

标签 python numpy plot histogram

我在尝试用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/

相关文章:

python - 如何获取数组中某个范围内或高于阈值的值的计数?

python - Python 2.7 中的 TwilioRestClient 错误

python - virtualenv - 鸟瞰理解

python - 终止 PyQt 应用程序中长时间运行的 Python 命令

Python-绘制相空间轨迹(颤动函数)

matlab - 在Matlab中正确绘制粗体轴

r - 如何使用ggplot2制作弯曲的雷达图?

python - 如何进一步锁定执行不受信任代码的 Google App Engine 应用程序?

python - 将 int 添加到 uint8 时出现奇怪的类型转换?

python - 按具有多个相似值的行对 Pandas 数据帧进行排序