在新的matplotlib.axis中使用现有matplotlib.axis

2024-09-29 21:38:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试实现一个由一个名为“Problem3Plot”的类和另一个名为“ProfilePlot”的类组成的结构。他们已经在工作,他们只是简单地读入一些数据,然后从中创建一个绘图。 现在,我想把它们放在一起;因此,应用某种组件模式(没有那么严格)

我只是将新matplotlib.axis指定为旧的matplotlib.axis。但是我的轴是空的,所以数据没有被绘制出来

下面是提到的代码:

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中,我将现有的轴指定为新对象的轴,但我得到的是-如前所述-只有空图

如何解决这个问题?谢谢


Tags: 数据selfobjectplotmatplotlibdefpltclass

热门问题