在 Matplotlib 中,fig.add_subplot(111) 中的参数是什么意思? [英] In Matplotlib, what does the argument mean in fig.add_subplot(111)?

查看:35
本文介绍了在 Matplotlib 中,fig.add_subplot(111) 中的参数是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我会遇到这样的代码:

Sometimes I come across code such as this:

import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
fig = plt.figure()
fig.add_subplot(111)
plt.scatter(x, y)
plt.show()

产生:

我一直在疯狂阅读文档,但我找不到 111 的解释.有时我会看到 212.

I've been reading the documentation like crazy but I can't find an explanation for the 111. sometimes I see a 212.

fig.add_subplot() 的参数是什么意思?

推荐答案

这些是编码为单个整数的子图网格参数.例如,111"表示1x1 网格,第一个子图",234"表示2x3 网格,第 4 个子图".

These are subplot grid parameters encoded as a single integer. For example, "111" means "1x1 grid, first subplot" and "234" means "2x3 grid, 4th subplot".

add_subplot(111) 的替代形式是 add_subplot(1, 1, 1).

这篇关于在 Matplotlib 中,fig.add_subplot(111) 中的参数是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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