将多个图包装在一个图像中 [英] Wrap multiple plots together in a single image

查看:48
本文介绍了将多个图包装在一个图像中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将许多图组合在一起,因为它们密切相关(使用 1 个连续变量和 1 个分类变量显示密度,按星期几细分,其中每一天都是不同的图).在 R 中,我可以使用 gridExtrafacet_wrap 中的 grid.arrange() 将可视化包装在一起以作为 1 个变量返回给用户,并且包含所有图的图像.它看起来像这样:

I am trying to wrap numerous plots together, as they are closely related (showing density using 1 continuous and 1 categorical variable, broken down by day of the week, where each day is a different plot). In R, I can either use grid.arrange() from gridExtra or facet_wrap to wrap visualizations together to return to the user as 1 variable and image containing all plots. It looks like this:

我如何在 Python 中执行此操作?

How do I do this in Python?

推荐答案

是的,这可以使用 matplotlib 子图.请参阅此 例子.

Yes, this can be done using matplotlib subplots. See this example.

可视化的布局可以使用所需的行数和列数进行初始化.每个单元格将包含一个不同的子图.

The layout of the visualization can be initialized with the desired number of rows and columns. Each cell will contain a different subplot.

fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))

这篇关于将多个图包装在一个图像中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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