@@ -31,11 +31,18 @@ def __init__(self, poster=False):
3131 def two_column_plot (self , nrows = 1 , ncolumns = 1 , heightratio = [1 ], widthratio = [1 ], height = 0 ):
3232 """ two_column_plot function
3333 takes data and makes a two-column width figure
34- ================INPUTS=============
35- npanels is panel matrix
36- ratios is size ratios of panels
37- ================OUTPUT=============
38- fig, axs are figure objects """
34+
35+ Args:
36+ nrows (int): number of rows
37+ ncolumns (int): number of columns
38+ heightratio (np.1darray): array of same length as number of rows
39+ widthratio (np.1darray): array of same length as number of columns
40+ height (float): if set, figure will be this height
41+
42+ Returns:
43+ fig (figure object): figure
44+ axs (axes object): axes
45+ """
3946
4047 # first, check everything matches
4148 try :
@@ -92,82 +99,20 @@ def two_column_plot(self, nrows=1, ncolumns=1, heightratio=[1], widthratio=[1],
9299 axs [i ,j ].yaxis .set_tick_params (width = 0.5 , length = lw * 4 )
93100 axs [i ,j ].tick_params (axis = 'both' , pad = 1.2 )
94101 return fig , axs
95-
96- def one_column_multirow_plot (self , nrows = 1 , ncolumns = 1 , heightratio = [1 ], widthratio = [1 ], height = 0 ):
97- """ one_column_multirow_plot function
98- takes data and makes a one-column width figure
99- ================INPUTS=============
100- npanels is panel matrix
101- ratios is size ratios of panels
102- ================OUTPUT=============
103- fig, axs are figure objects """
104-
105- # first, check everything matches
106- try :
107- if len (heightratio ) != nrows :
108- raise Exception ('Number of height ratios incorrect' )
109- if len (widthratio ) != ncolumns :
110- raise Exception ('Number of width ratios incorrect' )
111- except Exception as error :
112- print ('Caught this error: ' + repr (error ))
113- return
114-
115- if self .poster == True :
116- fontsz = 12
117- lw = 1
118- else :
119- fontsz = 7
120- lw = 1
121-
122- xsize = 3.33 # 3.33 inches for one-column figure
123- if height is not None :
124- ysize = np .min ([height , 8.25 ]) # maximum size in y can be 8.25
125- else :
126- ysize = np .min ([3.5 * nrows , 8.25 ]) # maximum size in y can be 8.25
127-
128- plt .rcParams ['figure.figsize' ] = [xsize , ysize ]
129- plt .rcParams ['font.size' ] = fontsz
130- plt .rcParams ['svg.fonttype' ] = 'none'
131- matplotlib .rcParams ['pdf.fonttype' ] = 42
132- matplotlib .rcParams ['ps.fonttype' ] = 42
133- plt .rcParams ['axes.linewidth' ] = lw # set the value globally
134-
135- fig , axs = plt .subplots (nrows , ncolumns , height_ratios = heightratio ,
136- width_ratios = widthratio ) # create number of panels
137-
138-
139- # clean up axes, tick parameters
140- if nrows * ncolumns == 1 :
141- axs .xaxis .set_tick_params (width = lw , length = lw * 4 )
142- axs .yaxis .set_tick_params (width = lw , length = lw * 4 )
143- axs .tick_params (axis = 'both' , pad = 1.2 )
144- elif nrows * ncolumns == 2 :
145- for i in np .arange (2 ):
146- axs [i ].xaxis .set_tick_params (width = lw , length = lw * 4 )
147- axs [i ].yaxis .set_tick_params (width = lw , length = lw * 4 )
148- axs [i ].tick_params (axis = 'both' , pad = 1.2 )
149- elif nrows * ncolumns == len (widthratio ):
150- for i in np .arange (len (widthratio )):
151- axs [i ].xaxis .set_tick_params (width = lw , length = lw * 4 )
152- axs [i ].yaxis .set_tick_params (width = lw , length = lw * 4 )
153- axs [i ].tick_params (axis = 'both' , pad = 1.2 )
154- else :
155- for i in np .arange (nrows ):
156- for j in np .arange (ncolumns ):
157- axs [i ,j ].xaxis .set_tick_params (width = 0.5 , length = lw * 4 )
158- axs [i ,j ].yaxis .set_tick_params (width = 0.5 , length = lw * 4 )
159- axs [i ,j ].tick_params (axis = 'both' , pad = 1.2 )
160- return fig , axs
161102
162103 def one_column_plot (self , npanels = 1 , ratios = [1 ], height = None ):
163104 """ one_column_plot function
164105 takes data and makes a one-column width figure
165- ================INPUTS=============
166- npanels is number of panels in the figure
167- ratios is size ratios of panels
168- height is figure height
169- ================OUTPUT=============
170- fig, axs are figure objects """
106+
107+ Args:
108+ npanels (int): number of panels in the figure
109+ ratios (np.1darray): size ratios of panels
110+ height (float): figure height
111+
112+ Returns:
113+ fig (figure object): figure
114+ axs (axes object): axes
115+ """
171116
172117 # first, check everything matches
173118 try :
@@ -251,18 +196,20 @@ def histogram_plot(self, axs, data, bins, xlim=None, ylim=None,
251196 histcolor = 'gray' , xaxislabel = 'x axis' , alpha = 1 , histtype = 'bar' , density = True ):
252197 """ histogram_plot function
253198 takes data and makes a histogram
254- ================INPUTS=============
255- data is data
256- bins are bins
257- xlim is x limits; default is None (which computes max/min)
258- ylim is y limits; default is None (which lets it keep its default)
259- histcolor is histogram colour (default is gray)
260- xaxislabel is x axis label (default is 'x axis')
261- alpha is histogram transparency (default 1)
262- density is if to plot as pdf, default yes
263- histtype is histogram type, default bar
264- ================OUTPUT=============
265- axs is axis object """
199+
200+ Args:
201+ data (np.1darray): data array
202+ bins (np.1darray): bin array
203+ xlim (boolean or list of two floats): default is None (which computes min/max of x), otherwise provide a min/max
204+ ylim (boolean or list of two floats): default is None (which computes min/max of y), otherwise provide a min/max
205+ histcolor (string): histogram colour (default is gray)
206+ xaxislabel (string): x axis label (default is 'x axis')
207+ alpha (float): histogram transparency (default 1)
208+ histtype (string): histogram type, default bar
209+ density (boolean): if to plot as pdf, default True
210+
211+ Returns:
212+ axs (axis): axis object """
266213 if self .poster == True :
267214 fontsz = 15
268215 else :
@@ -286,21 +233,20 @@ def histogram_plot(self, axs, data, bins, xlim=None, ylim=None,
286233 def scatter_plot (self , axs , x , y , xlim = None , ylim = None , label = '' ,
287234 edgecolor = 'k' , facecolor = 'white' , s = 5 , lw = 0.75 , xaxislabel = 'x axis' , yaxislabel = 'y axis' , alpha = 1 ):
288235 """ scatter_plot function
289- takes data and makes a scatter plot
290- ================INPUTS=============
291- x is x data
292- y os y data
293- xlim is x limits; default is None (which computes max/min)
294- ylim is y limits; default is None (which computes max/min)
295- label is label; default is nothing
296- edgecolor is edge colour; default is black
297- facecolor is face colour; default is white
298- s is size of scatter point; default is 5
299- lw is line width (default 0.75)
300- xaxislabel is x axis label (default is 'x axis')
301- yaxislabel is y axis label (default is 'y axis')
302- ================OUTPUT=============
303- axs is axis object """
236+ takes scatter data and makes an scatter plot
237+
238+ Args:
239+ xdata (np.1darray): scatter points, x
240+ ydata (np.1darray): scatter points, y
241+ xlim (np.1darray): x limits
242+ ylim (np.1darray): y limits
243+ label (string): any annotation
244+ edgecolor (string): colour of scatter plot edges
245+ facecolor (string): colour of scatter point faces
246+ alpha (float): transparency of points
247+
248+ Returns:
249+ axs (axis): axis object """
304250 if self .poster == True :
305251 fontsz = 15
306252 else :
@@ -322,19 +268,21 @@ def image_plot(self, axs, data, vmin=None, vmax=None, cmap='binary', cbar='on',
322268 labelcolor = 'black' , pixelsize = 69 , scalebarsize = 5000 , scalebarlabel = r'5$\,\mu$m' , alpha = 1 ):
323269 """ image_plot function
324270 takes image data and makes an image plot
325- ================INPUTS=============
326- data is image
327- vmin is minimum pixel displayed (default 99.9%)
328- vmax is maximum pixel displayed (default 0.1%)
329- cmap is colour map used; default gray
330- cbarlabel is colour bar label; default intensity
331- label is any annotation
332- labelcolor is annotation colour
333- pixelsize is pixel size in nm for scalebar, default 69
334- scalebarsize is scalebarsize in nm, default 5000
335- scalebarlabel is scale bar label, default 5 um
336- ================OUTPUT=============
337- axs is axis object """
271+
272+ Args:
273+ data (np.2darray): image
274+ vmin (float): minimum pixel intensity displayed (default 0.1%)
275+ vmax (float): minimum pixel intensity displayed (default 99.9%)
276+ cmap (string): colour map used; default gray)
277+ cbarlabel (string): colour bar label; default 'photons'
278+ label (string): is any annotation
279+ labelcolor (string): annotation colour
280+ pixelsize (float): pixel size in nm for scalebar, default 110
281+ scalebarsize (float): scalebarsize in nm, default 5000
282+ scalebarlabel (string): scale bar label, default 5 um
283+
284+ Returns:
285+ axs (axis): axis object """
338286 if vmin is None :
339287 vmin = np .percentile (data .ravel (), 0.1 )
340288 if vmax is None :
0 commit comments