【发布时间】:2018-12-31 17:32:48
【问题描述】:
我想创建一个带有 2x2 子图的图形。然后通过用户的一些输入(在不同的线程上),图形更改为 MxN 组子图,而无需创建另一个图形框。这可能吗?
x = [1,2,3]
y = [1,2,3]
fig, axs = plt.subplots(222)
threadedPlotShow(ax, x, y) #in a different thread, shows figure with xy on each
#wait for user input
m = raw_input("enter rows")
n = raw_input("enter cols")
update_figure(x,y,M,N,fig)
def update_figure(self, x, y, M, N, fig):
ax=fig.add_subplot(nrows=M,ncols=N, index=M+N+1)
ax.plot(x,y)
plt.draw()
这些帖子没有帮助,因为它创建了新的数字(至少在我的实施中,如果他们不应该让我知道,我会继续尝试): Dynamically add/create subplots in matplotlib
【问题讨论】:
-
您愿意详细说明为什么这些帖子没有帮助吗?你的情况有什么不同。至少从一开始,您需要的是这些帖子的组合。
-
@JoeyMallone 我尝试了这个组合,每次迭代我都会得到新的数字。我浏览了文档并提出了我添加的这个示例,但它不起作用......我现在将返回并再次尝试组合
-
@doctorlove 我不明白那个例子
-
我将 matplotlib 从 2.0.2 更新到 3.0.x 并使用了 gridspec 并且它有效...我应该删除问题吗?还是回答?
标签: python matplotlib