【发布时间】:2018-11-11 15:16:50
【问题描述】:
我正在尝试编写一个简单的核裂变模拟,到目前为止,我已经让核心本身的模拟正常工作。现在我想做的是在模拟附近有第二张图,告诉用户从核心输出了多少功率。
话虽如此,我正在尝试使用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()
就像我之前说的,我希望功率图靠近模拟,这将占据大部分图形,如下所示:
如果有任何帮助,我将不胜感激,谢谢!
【问题讨论】:
标签: python python-3.x animation matplotlib graph