我有一个 pandas 数据框,想要绘制一列中的值与另一列中的值。幸运的是,有plot
与数据帧关联的方法似乎可以满足我的需要:
df.plot(x='col_name_1', y='col_name_2')
不幸的是,它看起来像在情节风格中(列出here http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.plot.html之后kind
参数)没有点。我可以使用线条或条形,甚至密度,但不能使用点。是否有解决方法可以帮助解决此问题。
您可以指定style
调用时绘制的线df.plot http://pandas.pydata.org/pandas-docs/version/0.15.0/generated/pandas.DataFrame.plot.html?highlight=plot#pandas-dataframe-plot:
df.plot(x='col_name_1', y='col_name_2', style='o')
The style
参数也可以是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'])
所有接受的样式格式都列在文档中matplotlib.pyplot.plot http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)