列和行中的python pandas DataFrame子图 [英] python pandas DataFrame subplot in columns and rows

查看:350
本文介绍了列和行中的python pandas DataFrame子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据4列DataFrame到2行和2列中生成一个子图

I would like to produce a subplot from data 4 column DataFrame into 2 rows and 2 columns

df =pd.DataFrame(np.random.randn(6,4),index=pd.date_range('1/1/2000',periods=6, freq='1h'))

但是下面将给出4行1列的图

However below will give a 4 row and 1 column plot

 df.plot(use_index=False, title=f, subplots=True, sharey=True, figsize=(8, 6))

谢谢.

推荐答案

在当前版本的Pandas中,

In current versions of Pandas, DataFrame.plot features the layout keyword for this purpose.

df.plot(subplots=True, layout=(2,2), ...)

这篇关于列和行中的python pandas DataFrame子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆