簡體   English   中英

在 pandas.DataFrame.plot 中添加 X 軸標簽

[英]Add labels for X-axis in pandas.DataFrame.plot

我有一個 dataframe 包含一列c的一和零。 我想 plot 此列的直方圖。 我嘗試了以下方法:

    df.c.plot(kind='hist', weights = np.ones_like(df.index)/ len(df.index), title='Percentage', grid=True)

結果是一個帶有兩個條的 plot; 一個代表零值,一個代表一值。 如何為這兩個條添加標簽,比如在 x 軸上? 除了使用weights ,還有其他方法可以顯示百分比值嗎?

我有一個 dataframe 包含一列c的一和零。 我想 plot 此列的直方圖。 我嘗試了以下方法:

    df.c.plot(kind='hist', weights = np.ones_like(df.index)/ len(df.index), title='Percentage', grid=True)

結果是一個帶有兩個條的 plot; 一個代表零值,一個代表一值。 如何為這兩個條添加標簽,比如在 x 軸上? 除了使用weights ,還有其他方法可以顯示百分比值嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM