在Matplotlib中,该参数在fig.add_subplot(111)中意味着什么? [英] In Matplotlib, what does the argument mean in fig.add_subplot(111)?
本文介绍了在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屋!
查看全文