Matplotlib subplot2grid无法正常工作

时间:2018-06-01 13:05:30

标签: python python-3.x animation matplotlib graph

我正在尝试编写一个简单的核裂变模拟,到目前为止,我已经对核心本身的模拟工作正常。现在我要做的是在模拟附近有第二个图形,告诉用户从核心输出多少功率。

话虽如此,我正在尝试使用subtplot2grid,但我似乎无法为我的程序找到合适的测量值。我还在核心模拟中添加了一个plt.Rectangle的补丁,我用它作为我的核心的边界,我尝试运行带有和没有补丁的程序,看起来这是问题。尽管如此,我希望保留这个矩形,请帮助我找到合适的尺寸并解释为什么尺寸不同有无补丁。

这是我的代码:

import matplotlib.pyplot as plt
import matplotlib.animation as animation

BOUNDS = [-20,20,-20,20]

fig = plt.figure()

ax = plt.subplot2grid((3,2),(0,0), rowspan = 2, colspan = 2, aspect = 'equal', autoscale_on = False,
                          xlim = (-51.2,51.2), ylim = (-50.4,50.4))
ax1 = plt.subplot2grid((3,2),(2,1))

ax1.set_xlabel('Time')
ax1.set_ylabel('Jouls')

rect = plt.Rectangle(BOUNDS[::2], #Creates the frame of the board (black rectangle)
                 BOUNDS[1] - BOUNDS[0],
                 BOUNDS[3] - BOUNDS[2],
                 ec='black', lw=2, fc='none')


ax.add_patch(rect)
ax.axis('off')
plt.show()

如果您将运行该程序,您将看到: enter image description here

就像我之前说过的那样,我希望功率图靠近模拟,这将占据大部分数字,如下所示:

enter image description here

感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

可能你想使用一个额外的列,让“核心”图表跨越所有3行?

split(df[,'family'], df[, 'area'])

enter image description here

相关问题