如何绘制特定数据的直方图

How to plot Histogram on specific data

我正在读取 CSV 文件:

 Notation Level   RFResult   PRIResult   PDResult  Total Result
 AAA       1       1.23        0           2         3.23
 AAA       1       3.4         1           0         4.4
 BBB       2       0.26        1           1.42      2.68
 BBB       2       0.73        1           1.3       3.03
 CCC       3       0.30        0           2.73      3.03
 DDD       4       0.25        1           1.50      2.75
 ...
 ...

这是代码

import pandas as pd

df = pd.rad_csv('home\NewFiles\Files.csv')
Notation = df['Notation']
Level = df['Level']
RFResult = df['RFResult']
PRIResult = df['PRIResult']
PDResult = df['PDResult']

df.groupby('Level').plot(kind='bar')

上面的代码给了我四个不同的数字。我想更改以下几项:

  1. 我不想在图表中显示 LevelTotal Results 条。我应该如何删除它?

  2. 还有,我应该如何标记xaxis和yaxis以及每个图的标题。所以对于这个,我想给剧情的标题是“关卡号”。

要绘制,请使用以下代码...

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('home\NewFiles\Files.csv')
plt.hist((df['RFResult'],df['PRIResult'],df['PDResult']),bins=10)
plt.title('Level Number')
plt.xlabel('Label name')
plt.ylabel('Label name')
plt.plot()


  

你可以这样做:

import pandas as pd
import matplotlib.pyplot as plt
    
df = pd.read_csv('home\NewFiles\Files.csv')

df.plot(kind='hist', y = ['RFResult', 'PRIResult', 'PDResult'], bins=20)

plt.title('level numbers')
plt.xlabel('X-Label')
plt.ylabel('Y-Label')

Remember the plot is called by pandas, but is based on matplotlib. So you can pass additional arguments!