def draw(self): """ Clear and redraw the figure so it can be shown again """ self._internal = True # if self.fig: self.fig.clear() # if the fig is being redrawn, clear it first self.ax, self.fig = tfp.new_axis(self.subplot, fig_no=self.fig_no) self.set_strings() self.set_plot() self.shown = False self._internal = False
def __init__(self, x=None, y=None, title = None, subplot=111, defaults=1, text=None, block=True, dir_fig = './Figures/', fn='Figure_tmp', cm='jet'): ## Check arguments are as expected db(tx=type(x)) if not x==None: assert type(x) == ParamFloat, 'x plotting variable must be a <ParamFloat> (tuple not accepted)' if not y==None: assert type(y) == ParamFloat or (type(y) == tuple and type(y[0])==ParamFloat), 'y plotting variable must be a <ParamFloat> or tuple of <ParamFloat>s' if text: assert (type(text)==tuple and len(text)>=3), 'text keyword must have format (x,y,str,{fontsize})' PlotLines.nfig += 1 # Increase counter for number of plot instances self.fig_no = PlotLines.nfig # Set the figure number to the number of this instance self.shown = False ## Store arguments in self self.fig = None self.title = title self.x = x self.y = tf_simple.make_iter(y) # Always make y a tuple even if it only contains one set of data self.text = [] # text is a list of tuples containing (x,y,str,{fontsize}) if text: self.text.append(text) # Text to annotate plot self.subplot = subplot self.block = block self.dir_fig = dir_fig self.fn = fn self.cm = cm ## Set default mpl properties (font sizes etc) tfp.set_mpl_defaults(defaults=defaults) plt.ion() # Interactive plotting (draw implicit) ## Create the figure and axes self.ax, self.fig = tfp.new_axis(subplot, fig_no=self.fig_no) ## Set axis title and labels if self.title: self.set_title(title) if not self.x == None: self.set_xlabel(self.x.label()) if not self.y == None: self.set_ylabel(self.y[0].label()) # set y axis using first y parameter in tuple if text: self.set_text()
def __init__(self, x=None, y=None, title=None, subplot=111, defaults=1, text=None, block=True, dir_fig='./Figures/', fn='Figure_tmp', cm='jet'): ## Check arguments are as expected db(tx=type(x)) if not x == None: assert type( x ) == ParamFloat, 'x plotting variable must be a <ParamFloat> (tuple not accepted)' if not y == None: assert type(y) == ParamFloat or ( type(y) == tuple and type(y[0]) == ParamFloat ), 'y plotting variable must be a <ParamFloat> or tuple of <ParamFloat>s' if text: assert (type(text) == tuple and len(text) >= 3 ), 'text keyword must have format (x,y,str,{fontsize})' PlotLines.nfig += 1 # Increase counter for number of plot instances self.fig_no = PlotLines.nfig # Set the figure number to the number of this instance self.shown = False ## Store arguments in self self.fig = None self.title = title self.x = x self.y = tf_simple.make_iter( y ) # Always make y a tuple even if it only contains one set of data self.text = [ ] # text is a list of tuples containing (x,y,str,{fontsize}) if text: self.text.append(text) # Text to annotate plot self.subplot = subplot self.block = block self.dir_fig = dir_fig self.fn = fn self.cm = cm ## Set default mpl properties (font sizes etc) tfp.set_mpl_defaults(defaults=defaults) plt.ion() # Interactive plotting (draw implicit) ## Create the figure and axes self.ax, self.fig = tfp.new_axis(subplot, fig_no=self.fig_no) ## Set axis title and labels if self.title: self.set_title(title) if not self.x == None: self.set_xlabel(self.x.label()) if not self.y == None: self.set_ylabel(self.y[0].label() ) # set y axis using first y parameter in tuple if text: self.set_text()