python - Pandas 情节 : how to plot some columns of a dataframe with the same color but different style and some cols with different color and different style?

标签 python pandas

假设 DataFrame df 具有三个系列:S1S2S3

我想画

  • S1 具有蓝色和连续线,
  • S2,蓝色和虚线,
  • S3,绿色,连续线。

我可以调用Series.plot()三次,但是如果我想使用DataFrame.plot()怎么办?
换句话说,我想使用方法 df[[S1,S2,S3]].plot() 但我不知道要传递给方法 plot()< 的参数。 到目前为止,我只发现我可以传递 matplotlib colormap 但这似乎并不能解决我的问题。

最佳答案

使用style选项:

linestyles = ['b', 'b--', 'g']
df.plot(style=linestyles)

enter image description here

关于python - Pandas 情节 : how to plot some columns of a dataframe with the same color but different style and some cols with different color and different style?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71843977/

相关文章:

python - 写入使用 Paramiko/pysftp "open"方法打开的 SFTP 服务器上的文件很慢

python - 在 Python 中将小时和分钟转换为总分钟

python - 更改密码,python,linux

pandas - 在 pandas 中使用变量名作为列名

python - 如何更快地使用 Google map 进行地理编码?

python - 带有实例变量的 Pandas 自定义访问器

python - 使用 pygame.time.set_timer

Python Plotly 条形图对 csv 中的项目进行计数

python - 将诸如 "6:02PM"之类的仅限时间的字符串转换为日期时间对象?

python - 打印时从字典的值中删除括号