如何用点绘制两列大 pandas 数据框? [英] How to plot two columns of a pandas data frame using points?
问题描述
plot
方法 df.plot(x ='col_name_1',y ='col_name_2')
不幸的是,它在绘图风格之间(这里后面的 kind
参数)没有点。我可以使用线或条,甚至密度,但不能使用点。有一个工作可以帮助解决这个问题。
您可以指定 style
在调用 df.plot
:
df.plot(x ='col_name_1',y ='col_name_2',style ='o')
样式
参数也可以是 dict
或列表
,例如:
import numpy as np
import pandas as pd
d = {'one':np.random.rand(10),
'two':np.random.rand(10)}
df = pd.DataFrame (d)
df.plot(style = ['o','rx'])
所有接受的样式格式都列在 matplotlib.pyplot.plot
。
I have a pandas data frame and would like to plot values from one column versus the values from another column. Fortunately, there is plot
method associated with the data-frames that seems to do what I need:
df.plot(x='col_name_1', y='col_name_2')
Unfortunately, it looks like among the plot styles (listed here after the kind
parameter) there are not points. I can use lines or bars or even density but not points. Is there a work around that can help to solve this problem.
You can specify the style
of the plotted line when calling df.plot
:
df.plot(x='col_name_1', y='col_name_2', style='o')
The style
argument can also be a dict
or list
, e.g.:
import numpy as np
import pandas as pd
d = {'one' : np.random.rand(10),
'two' : np.random.rand(10)}
df = pd.DataFrame(d)
df.plot(style=['o','rx'])
All the accepted style formats are listed in the documentation of matplotlib.pyplot.plot
.
这篇关于如何用点绘制两列大 pandas 数据框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!