Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用标记生成CDF图_Python_Python 3.x_Matplotlib - Fatal编程技术网

Python 使用标记生成CDF图

Python 使用标记生成CDF图,python,python-3.x,matplotlib,Python,Python 3.x,Matplotlib,这似乎是一个微不足道的问题,但我不知道如何绘制原始CDF数据和放置标记。以下是数据的外观: 10.45 925.0 20.56 928.0 30.63 948.0 50.10 955.0 80.62 961.0 90.00 978.0 98.89 1026.0 第1列为%,第2列为数值。例如,10.45%的用户存储925MB或更少。我想: 绘制CDF的png图表 在这个图表上有10%,50%,90%,99%的标记。 如何在python中实现这一点?我基本上没有策划经验 可以使用绘制原始CDF。

这似乎是一个微不足道的问题,但我不知道如何绘制原始CDF数据和放置标记。以下是数据的外观:

10.45 925.0
20.56 928.0
30.63 948.0
50.10 955.0
80.62 961.0
90.00 978.0
98.89 1026.0
第1列为%,第2列为数值。例如,10.45%的用户存储925MB或更少。我想:

  • 绘制CDF的png图表
  • 在这个图表上有10%,50%,90%,99%的标记。 如何在python中实现这一点?我基本上没有策划经验

  • 可以使用绘制原始CDF。您可以选择如何绘制步骤:
    pre
    表示从
    x[i-1]
    绘制到
    x[i]
    (默认)或
    post
    x[i]
    x[i+1]
    y行

    (我假设您指的是记号,可能是y轴上的网格线,如果您的数据包含精确标记值的条目(例如90%),则不清楚将标记放置在何处。)

    import numpy as np
    import matplotlib.pyplot as plt
    
    a = np.array([[  10.45,  925.  ],
           [  20.56,  928.  ],
           [  30.63,  948.  ],
           [  50.1 ,  955.  ],
           [  80.62,  961.  ],
           [  90.  ,  978.  ],
           [  98.89, 1026.  ]])
    
    fig, (ax1, ax2) = plt.subplots(ncols=2)
    ticks = [10, 50, 90, 99]
    ticklabels = [f'{t} %' for t in ticks]
    
    ax1.step(a[:,1], a[:,0], where='pre')  # default
    ax1.yaxis.set_ticks(ticks)
    ax1.yaxis.set_ticklabels(ticklabels)
    ax1.yaxis.grid(True)
    ax1.set_ylim(0, 100)
    ax1.set_title('pre')
    
    ax2.step(a[:,1], a[:,0], where='post')
    ax2.yaxis.set_ticks(ticks)
    ax2.yaxis.set_ticklabels(ticklabels)
    ax2.yaxis.grid(True)
    ax2.set_ylim(0, 100)
    ax2.set_title('post')