Loading src/yapsut/AppendableDict.py +9 −13 Original line number Original line Diff line number Diff line Loading @@ -7,19 +7,15 @@ import time class AppendableDict : class AppendableDict : """ a dictionary, whose arguments are lists which can be appended """ a dictionary, whose arguments are lists which can be appended Example: Examples: >AD=AppendableDict() >>>AD=AppendableDict() > >>>AD['line1']=1 >AD['line1']=1 >>>AD['line2']=10 >AD['line2']=10 >>>AD['line1']=2 > >>>AD['line2']=20 >AD['line1']=2 >>>AD['line1']=3 >AD['line2']=20 >>>AD['line2']=30 > >>>print(AD['line1']) >AD['line1']=3 >AD['line2']=30 > >print(AD['line1']) [1,2,3] [1,2,3] """ """ Loading src/yapsut/graphics.py +63 −10 Original line number Original line Diff line number Diff line Loading @@ -204,7 +204,34 @@ class StandardFig() : def split_path_setter(self,this) : def split_path_setter(self,this) : self._split_path=(this==True) self._split_path=(this==True) # # @property def fig(self) : """ handle for fig """ try : return self._handle['fig'] except : return None # @property def handle(self) : """ dictionary of graphic objects handles """ return self._handle # def __init__(self,figpath=None,figside=16,figratio=2/3,Creator='', Copyright='',Author='',split_path=False) : def __init__(self,figpath=None,figside=16,figratio=2/3,Creator='', Copyright='',Author='',split_path=False) : """ Creates a StandardFig object :Keywords: figpath = path for the figure (None) figside = horizontal side of the figure [in] (16) figratio = V/H ratio of figure (2/3) split_path = if True the path is splitted (False) Creator = creator Author = Author Name Copyright = copyright string To have the handles to the figure components use the .handle dictionary. """ self.free_metadata() self.free_metadata() # # self._activated=True self._activated=True Loading @@ -225,13 +252,17 @@ class StandardFig() : self.Creator=Creator self.Creator=Creator self.Copyright=Copyright self.Copyright=Copyright # # self.fig=None # list of handles for various objects self._handle={} # # self.fontsize_ticks=16 self.fontsize_ticks=16 self.fontsize_labels=18 self.fontsize_labels=18 self.fontsize_xylabels=18 self.fontsize_xylabels=18 self.fontsize_title=18 self.fontsize_title=18 self.fontsize_legend=18 self.fontsize_legend=18 self.fontsize_legend_title=18 # self.legend_framealpha=None def copy(self) : def copy(self) : import copy import copy return self.deepcopy(self) return self.deepcopy(self) Loading @@ -239,34 +270,56 @@ class StandardFig() : return self.new(squared=squared) return self.new(squared=squared) def new(self,squared=False) : def new(self,squared=False) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt self._handle={} if squared : if squared : self.fig=plt.figure(figsize=(self.figside,self.figside)); self._handle['fig']=plt.figure(figsize=(self.figside,self.figside)); else : else : self.fig=plt.figure(figsize=self.figsize); self._handle['fig']=plt.figure(figsize=self.figsize); self.fig.canvas.toolbar_visible = True self.fig.canvas.toolbar_visible = True self.fig.canvas.header_visible = False self.fig.canvas.header_visible = False self.fig.canvas.resizable = True self.fig.canvas.resizable = True return self.fig return self.fig def legend(self,ncol=1,loc=1,title='',fontsize=None) : def legend(self,ncol=1,loc=1,title='',fontsize=None,ax=None,title_fontsize=None,LISTP=None,legend_framealpha=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_legend if fontsize is None else fontsize fsl=self.fontsize_legend if fontsize is None else fontsize return plt.legend(ncol=ncol,loc=loc,fontsize=fs,title=title) fslt=self.fontsize_legend_title if title_fontsize is None else title_fontsize falpha=self.legend_framealpha if legend_framealpha is None else legend_framealpha self.ax_legend=None ax1=plt.gca() if ax==None else ax # if LISTP==None : self._handle['legend']=ax1.legend(ncol=ncol,loc=loc,fontsize=fsl,title=title,title_fontsize=fslt) return self._handle['legend'] # lns = LISTP[0] for ik in range(len(LISTP)) : if ik == 0 : lns=LISTP[0] else : lns += LISTP[ik] labs = [l.get_label() for l in lns] self._handle['legend']=ax1.legend(lns, labs,ncol=ncol,loc=loc,fontsize=self.fontsize_legend if fontsize is None else fontsize,title=title,title_fontsize=fslt) return self._handle['legend'] def title(self,txt,fontsize=None) : def title(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_title if fontsize is None else fontsize fs=self.fontsize_title if fontsize is None else fontsize return plt.title(txt,fontsize=fs) self._handle['title']=plt.title(txt,fontsize=fs) return self._handle['title'] def suptitle(self,txt,fontsize=None) : def suptitle(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_title if fontsize is None else fontsize fs=self.fontsize_title if fontsize is None else fontsize return plt.suptitle(txt,fontsize=fs) self._handle['suptitle']=plt.suptitle(txt,fontsize=fs) return self._handle['suptitle'] def xlabel(self,txt,fontsize=None) : def xlabel(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_xylabels if fontsize is None else fontsize fs=self.fontsize_xylabels if fontsize is None else fontsize return plt.xlabel(txt,fontsize=fs) self._handle['xlabel']=plt.xlabel(txt,fontsize=fs) return self._handle['xlabel'] def ylabel(self,txt,fontsize=None) : def ylabel(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_xylabels if fontsize is None else fontsize fs=self.fontsize_xylabels if fontsize is None else fontsize return plt.ylabel(txt,fontsize=fs) self._handle['ylabel']=plt.ylabel(txt,fontsize=fs) return self._handle['ylabel'] def XTICKS(self,ax=None,fontsize=None) : def XTICKS(self,ax=None,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_ticks if fontsize is None else fontsize fs=self.fontsize_ticks if fontsize is None else fontsize Loading Loading
src/yapsut/AppendableDict.py +9 −13 Original line number Original line Diff line number Diff line Loading @@ -7,19 +7,15 @@ import time class AppendableDict : class AppendableDict : """ a dictionary, whose arguments are lists which can be appended """ a dictionary, whose arguments are lists which can be appended Example: Examples: >AD=AppendableDict() >>>AD=AppendableDict() > >>>AD['line1']=1 >AD['line1']=1 >>>AD['line2']=10 >AD['line2']=10 >>>AD['line1']=2 > >>>AD['line2']=20 >AD['line1']=2 >>>AD['line1']=3 >AD['line2']=20 >>>AD['line2']=30 > >>>print(AD['line1']) >AD['line1']=3 >AD['line2']=30 > >print(AD['line1']) [1,2,3] [1,2,3] """ """ Loading
src/yapsut/graphics.py +63 −10 Original line number Original line Diff line number Diff line Loading @@ -204,7 +204,34 @@ class StandardFig() : def split_path_setter(self,this) : def split_path_setter(self,this) : self._split_path=(this==True) self._split_path=(this==True) # # @property def fig(self) : """ handle for fig """ try : return self._handle['fig'] except : return None # @property def handle(self) : """ dictionary of graphic objects handles """ return self._handle # def __init__(self,figpath=None,figside=16,figratio=2/3,Creator='', Copyright='',Author='',split_path=False) : def __init__(self,figpath=None,figside=16,figratio=2/3,Creator='', Copyright='',Author='',split_path=False) : """ Creates a StandardFig object :Keywords: figpath = path for the figure (None) figside = horizontal side of the figure [in] (16) figratio = V/H ratio of figure (2/3) split_path = if True the path is splitted (False) Creator = creator Author = Author Name Copyright = copyright string To have the handles to the figure components use the .handle dictionary. """ self.free_metadata() self.free_metadata() # # self._activated=True self._activated=True Loading @@ -225,13 +252,17 @@ class StandardFig() : self.Creator=Creator self.Creator=Creator self.Copyright=Copyright self.Copyright=Copyright # # self.fig=None # list of handles for various objects self._handle={} # # self.fontsize_ticks=16 self.fontsize_ticks=16 self.fontsize_labels=18 self.fontsize_labels=18 self.fontsize_xylabels=18 self.fontsize_xylabels=18 self.fontsize_title=18 self.fontsize_title=18 self.fontsize_legend=18 self.fontsize_legend=18 self.fontsize_legend_title=18 # self.legend_framealpha=None def copy(self) : def copy(self) : import copy import copy return self.deepcopy(self) return self.deepcopy(self) Loading @@ -239,34 +270,56 @@ class StandardFig() : return self.new(squared=squared) return self.new(squared=squared) def new(self,squared=False) : def new(self,squared=False) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt self._handle={} if squared : if squared : self.fig=plt.figure(figsize=(self.figside,self.figside)); self._handle['fig']=plt.figure(figsize=(self.figside,self.figside)); else : else : self.fig=plt.figure(figsize=self.figsize); self._handle['fig']=plt.figure(figsize=self.figsize); self.fig.canvas.toolbar_visible = True self.fig.canvas.toolbar_visible = True self.fig.canvas.header_visible = False self.fig.canvas.header_visible = False self.fig.canvas.resizable = True self.fig.canvas.resizable = True return self.fig return self.fig def legend(self,ncol=1,loc=1,title='',fontsize=None) : def legend(self,ncol=1,loc=1,title='',fontsize=None,ax=None,title_fontsize=None,LISTP=None,legend_framealpha=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_legend if fontsize is None else fontsize fsl=self.fontsize_legend if fontsize is None else fontsize return plt.legend(ncol=ncol,loc=loc,fontsize=fs,title=title) fslt=self.fontsize_legend_title if title_fontsize is None else title_fontsize falpha=self.legend_framealpha if legend_framealpha is None else legend_framealpha self.ax_legend=None ax1=plt.gca() if ax==None else ax # if LISTP==None : self._handle['legend']=ax1.legend(ncol=ncol,loc=loc,fontsize=fsl,title=title,title_fontsize=fslt) return self._handle['legend'] # lns = LISTP[0] for ik in range(len(LISTP)) : if ik == 0 : lns=LISTP[0] else : lns += LISTP[ik] labs = [l.get_label() for l in lns] self._handle['legend']=ax1.legend(lns, labs,ncol=ncol,loc=loc,fontsize=self.fontsize_legend if fontsize is None else fontsize,title=title,title_fontsize=fslt) return self._handle['legend'] def title(self,txt,fontsize=None) : def title(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_title if fontsize is None else fontsize fs=self.fontsize_title if fontsize is None else fontsize return plt.title(txt,fontsize=fs) self._handle['title']=plt.title(txt,fontsize=fs) return self._handle['title'] def suptitle(self,txt,fontsize=None) : def suptitle(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_title if fontsize is None else fontsize fs=self.fontsize_title if fontsize is None else fontsize return plt.suptitle(txt,fontsize=fs) self._handle['suptitle']=plt.suptitle(txt,fontsize=fs) return self._handle['suptitle'] def xlabel(self,txt,fontsize=None) : def xlabel(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_xylabels if fontsize is None else fontsize fs=self.fontsize_xylabels if fontsize is None else fontsize return plt.xlabel(txt,fontsize=fs) self._handle['xlabel']=plt.xlabel(txt,fontsize=fs) return self._handle['xlabel'] def ylabel(self,txt,fontsize=None) : def ylabel(self,txt,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_xylabels if fontsize is None else fontsize fs=self.fontsize_xylabels if fontsize is None else fontsize return plt.ylabel(txt,fontsize=fs) self._handle['ylabel']=plt.ylabel(txt,fontsize=fs) return self._handle['ylabel'] def XTICKS(self,ax=None,fontsize=None) : def XTICKS(self,ax=None,fontsize=None) : from matplotlib import pyplot as plt from matplotlib import pyplot as plt fs=self.fontsize_ticks if fontsize is None else fontsize fs=self.fontsize_ticks if fontsize is None else fontsize Loading