diff --git a/src/yapsut/graphics.py b/src/yapsut/graphics.py index 9b309af237025d1b7e3f7a994ce889bf81493935..9041499de747ead4c136a94f6596ddca2d0c2b5a 100644 --- a/src/yapsut/graphics.py +++ b/src/yapsut/graphics.py @@ -35,6 +35,30 @@ def curveXY2patch(x,y,returnVectors=False,closed=True,draw=True, ax=None,color=N else: return plt.gca().add_collection(PatchCollection([pol])) +def curves2xy(Cup,Cdown,closed=True) : + """ converts an up curve and a down curve into a list of points to generate a partch + + Cup, Cdown = curves = [X,Y] + assumed that Cup, Cdown have increasing X + + the composed curve [X,Y] is oriented anticlockwise sense: + up: increasing X + down: decreasing X + + closed = True, the curve is closed, otherwise is left open + + Example: + X,Y=curves2xy([np.arange(5),np.arange(5)+10],[np.arange(5),-np.arange(5)]) + plt.plot(X,Y) + """ + import numpy as np + idxU=np.argsort(Cup[0]) + idxD=np.argsort(Cdown[0]) + idxD=np.array([idxD[k] for k in range(len(idxD)-1,-1,-1)],dtype=int) + idxO=np.array([0],dtype=int) if closed else [] + X=np.concatenate([Cup[0][idxU],Cdown[0][idxD],Cup[0][idxO]]) + Y=np.concatenate([Cup[1][idxU],Cdown[1][idxD],Cup[1][idxO]]) + return X,Y class _SaveFig : class __history_fig : @@ -260,14 +284,25 @@ class StandardFig() : # list of handles for various objects self._handle={} # - self.fontsize_ticks=16 - self.fontsize_labels=18 - self.fontsize_xylabels=18 - self.fontsize_title=18 - self.fontsize_legend=18 - self.fontsize_legend_title=18 + self.setfonts4paper() # self.legend_framealpha=None + def setfonts4paper(self) : + """sets figures with proportions for paper""" + self.fontsize_xylabels=18 + self.fontsize_ticks=16 + self.fontsize_labels=18 + self.fontsize_title=18 + self.fontsize_legend=18 + self.fontsize_legend_title=18 + def setfonts4slides(self) : + """sets figures with proportions for 16:9 slides""" + self.fontsize_xylabels=32 + self.fontsize_ticks=28 + self.fontsize_labels=self.fontsize_xylabels + self.fontsize_title=32 + self.fontsize_legend=self.fontsize_xylabels + self.fontsize_legend_title=self.fontsize_xylabels def copy(self) : import copy return self.deepcopy(self)