【问题标题】:How to increase Y axis limit on matplotlib? [duplicate]如何增加 matplotlib 的 Y 轴限制? [复制]
【发布时间】:2021-09-27 08:13:04
【问题描述】:
def doAnchoreGraph(image):
    print(image)
    info = infoAnchoreLog(image)
    window = Toplevel()
    window.title('Report '+ image)
    window.geometry("1000x1000")
    data = {'CVE': ['1. CRITICAL','2. HIGH','3. MEDIUM','4. LOW'],
                'Frequency': [info[1],info[2],info[3],info[4]]
            }
    df = DataFrame(data,columns=['CVE','Frequency'])
        
    figure = plt.Figure(figsize=(9,8), dpi=100)
    ax = figure.add_subplot(111)
    bar = FigureCanvasTkAgg(figure, window)
    bar.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH)
    df = df[['CVE','Frequency']].groupby('CVE').sum()
    df.plot(kind='bar', legend=True, ax=ax)
    ax.set_title("Scanned Image: "+ image)
    
    filename = "anchorescan-" + image + ".png" 
    figure.savefig(filename)

有人知道如何增加Y轴的极限吗?由于某种原因,我的上限为 20。这是我的示例输出: doAnchoreGraph.png

【问题讨论】:

  • ylim 是你要搜索的函数。

标签: python-3.x matplotlib tkinter matplotlib-widget


【解决方案1】:

ax.set_ylim(start,end) 应该可以解决问题。

【讨论】:

  • 您应该进一步说明此方法的作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-16
  • 2020-06-30
相关资源
最近更新 更多