Python 在新matplotlib.axis中使用现有matplotlib.axis
我试图实现一个由一个名为“Problem3Plot”的类和另一个名为“ProfilePlot”的类组成的结构。他们已经在工作,他们只是简单地读取一些数据,然后从中创建一个绘图。 现在,我想把它们放在一起;因此,应用某种组件模式(没有那么严格) 我只是将新matplotlib.axis指定给旧的matplotlib.axis。但是我的轴是空的,因此数据没有被绘制出来 以下是提到的代码:Python 在新matplotlib.axis中使用现有matplotlib.axis,python,matplotlib,plot,scientific-computing,Python,Matplotlib,Plot,Scientific Computing,我试图实现一个由一个名为“Problem3Plot”的类和另一个名为“ProfilePlot”的类组成的结构。他们已经在工作,他们只是简单地读取一些数据,然后从中创建一个绘图。 现在,我想把它们放在一起;因此,应用某种组件模式(没有那么严格) 我只是将新matplotlib.axis指定给旧的matplotlib.axis。但是我的轴是空的,因此数据没有被绘制出来 以下是提到的代码: class ProfilePlot(object): def __init__(self): # Su
class ProfilePlot(object):
def __init__(self):
# Subplot axes
self.uAxis = plt.subplot2grid((2,1),(0,0))
self.druAxis = plt.subplot2grid((2,1),(1,0))
self.axes = [self.uAxis,self.druAxis]
def plot(self):
self.uAxis.plot(...)
self.druAxis.plot(...)
class Problem3Plot(object):
def plotSetup(self):
self.mainAxis = plt.subplot2grid((1,1),(0,0))
self.mainAxis.plot(...)
class PloblemProfilePlot(object):
def plot(self):
self.problemAxis = ProblemPlotInstance.mainAxis
self.problemUAxis = ProfilePlotInstance.uAxis
self.problemDruAxis = ProfilePlotInstance.druAxis
在PloblemProfilePlot.plot中,我将现有轴指定为新对象的轴,但正如前面提到的,我得到的只是空图
我如何解决这个问题?谢谢 您能否尝试提取与问题相关的少数几行代码,并发布一些单独复制此问题的代码?请参阅和(r,但仍然相关)。感谢您的建议。好了!这并不是我想要的(也就是说,它应该是我们可以复制、粘贴和运行的代码),但是如果它有帮助,您可以在这里看到一些如何布置多个绘图的示例: