2424
2525# FIXME - make this return the figure object in the future, so several views
2626# can be composed.
27- def plot_funcs (pairlist , labels = None , offset = "auto" , rmin = None , rmax = None ):
28- """Plots several functions g(r ) on top of one another.
27+ def plot_funcs (pairlist , labels = None , offset = "auto" , xmin = None , xmax = None ):
28+ """Plots several functions f(x ) on top of one another.
2929
3030 Parameters
3131 ----------
3232 pairlist
33- Iterable of (r, gr ) pairs to plot.
33+ Iterable of (x, fx ) pairs to plot.
3434 labels
3535 Iterable of names for the pairs. If this is not the same length as
3636 the pairlist, a legend will not be shown (default []).
3737 offset
3838 Offset to place between plots. Functions will be sequentially shifted
3939 in the y-direction by the offset. If offset is 'auto' (default), the
4040 optimal offset will be determined automatically.
41- rmin
41+ xmin
4242 The minimum r-value to plot. If this is None (default), the lower
4343 bound of the function is not altered.
44- rmax
44+ xmax
4545 The maximum r-value to plot. If this is None (default), the upper
4646 bound of the function is not altered.
4747 """
@@ -55,25 +55,25 @@ def plot_funcs(pairlist, labels=None, offset="auto", rmin=None, rmax=None):
5555 labels .extend (["" ] * gap )
5656
5757 for idx , pair in enumerate (pairlist ):
58- r , gr = pair
59- plt .plot (r , gr + idx * offset , label = labels [idx ])
60- plt .xlim (rmin , rmax )
58+ x , fx = pair
59+ plt .plot (x , fx + idx * offset , label = labels [idx ])
60+ plt .xlim (xmin , xmax )
6161
6262 if gap == 0 :
6363 plt .legend (loc = 0 )
6464
6565 plt .legend ()
66- plt .xlabel (r"$r (\mathrm{\AA})$" )
67- plt .ylabel (r"$G (\mathrm{\AA}^{-1})$" )
66+ # plt.xlabel(r"$r (\mathrm{\AA})$")
67+ # plt.ylabel(r"$G (\mathrm{\AA}^{-1})$")
6868 plt .show ()
6969 return
7070
7171
7272def compare_funcs (
7373 pairlist ,
7474 labels = None ,
75- rmin = None ,
76- rmax = None ,
75+ xmin = None ,
76+ xmax = None ,
7777 show = True ,
7878 maglim = None ,
7979 mag = 5 ,
@@ -94,11 +94,11 @@ def compare_funcs(
9494 labels
9595 Iterable of names for the pairs. If this is not the same length as
9696 the pairlist, a legend will not be shown (default []).
97- rmin
98- The minimum r -value to plot. If this is None (default), the lower
97+ xmin
98+ The minimum x -value to plot. If this is None (default), the lower
9999 bound of the function is not altered.
100- rmax
101- The maximum r -value to plot. If this is None (default), the upper
100+ xmax
101+ The maximum x -value to plot. If this is None (default), the upper
102102 bound of the function is not altered.
103103 show
104104 Show the plot (default True)
@@ -119,24 +119,24 @@ def compare_funcs(
119119 else :
120120 labeldata = labels [1 ]
121121 labelfit = labels [0 ]
122- rfit , grfit = pairlist [0 ]
123- rdat , grdat = pairlist [1 ]
122+ xfit , fxfit = pairlist [0 ]
123+ xdat , fxdat = pairlist [1 ]
124124
125125 # View min and max
126- rvmin = max (rfit [0 ], rdat [0 ])
127- rvmin = rmin or rvmin
128- rvmax = min (rfit [- 1 ], rdat [- 1 ])
129- rvmax = rmax or rvmax
126+ xvmin = max (xfit [0 ], xdat [0 ])
127+ xvmin = xmin or xvmin
128+ xvmax = min (xfit [- 1 ], xdat [- 1 ])
129+ xvmax = xmax or xvmax
130130
131131 gap = 2 - len (labels )
132132 labels = list (labels )
133133 labels .extend (["" ] * gap )
134134
135- # Put gr1 on the same grid as rdat
136- gtemp = numpy .interp (rdat , rfit , grfit )
135+ # Put fx1 on the same grid as xdat
136+ ftemp = numpy .interp (xdat , xfit , fxfit )
137137
138138 # Calculate the difference
139- diff = grdat - gtemp
139+ diff = fxdat - ftemp
140140
141141 # Put rw in the label
142142 labeldiff = "difference" if len (labels ) < 3 else labels [2 ]
@@ -145,24 +145,24 @@ def compare_funcs(
145145
146146 # Magnify if necessary
147147 if maglim is not None :
148- grfit = grfit .copy ()
149- grfit [ rfit > maglim ] *= mag
150- sel = rdat > maglim
151- grdat = grdat .copy ()
152- grdat [sel ] *= mag
148+ fxfit = fxfit .copy ()
149+ fxfit [ xfit > maglim ] *= mag
150+ sel = xdat > maglim
151+ fxdat = fxdat .copy ()
152+ fxdat [sel ] *= mag
153153 diff [sel ] *= mag
154- gtemp [sel ] *= mag
154+ ftemp [sel ] *= mag
155155
156156 # Determine the offset for the difference curve.
157- sel = numpy .logical_and (rdat <= rvmax , rdat >= rvmin )
158- ymin = min (min (grdat [sel ]), min (gtemp [sel ]))
157+ sel = numpy .logical_and (xdat <= xvmax , xdat >= xvmin )
158+ ymin = min (min (fxdat [sel ]), min (ftemp [sel ]))
159159 ymax = max (diff [sel ])
160160 offset = - 1.1 * (ymax - ymin )
161161
162162 # Scale the x-limit based on the r-extent of the signal. This gives a nice
163163 # density of function peaks.
164- rlim = rvmax - rvmin
165- scale = rlim / 25.0
164+ xlim = xvmax - xvmin
165+ scale = xlim / 25.0
166166 # Set a reasonable minimum of .8 and maximum of 1
167167 scale = min (1 , max (scale , 0.8 ))
168168 figsize = [13.5 , 4.5 ]
@@ -177,12 +177,12 @@ def compare_funcs(
177177 fig .add_axes (axes )
178178 plt .minorticks_on ()
179179
180- plt .plot (rdat , grdat , linewidth = l_width , label = labeldata )
181- plt .plot (rfit , grfit , linewidth = l_width , label = labelfit )
182- plt .plot (rdat , offset * numpy .ones_like (diff ), linewidth = 3 , color = "black" )
180+ plt .plot (xdat , fxdat , linewidth = l_width , label = labeldata )
181+ plt .plot (xfit , fxfit , linewidth = l_width , label = labelfit )
182+ plt .plot (xdat , offset * numpy .ones_like (diff ), linewidth = 3 , color = "black" )
183183
184184 diff += offset
185- plt .plot (rdat , diff , linewidth = l_width , label = labeldiff )
185+ plt .plot (xdat , diff , linewidth = l_width , label = labeldiff )
186186
187187 if maglim is not None :
188188 # Add a line for the magnification cutoff
@@ -196,14 +196,14 @@ def compare_funcs(
196196 dashes = (14 , 7 ),
197197 )
198198 # FIXME - look for a place to put the maglim
199- xpos = (rvmax * 0.85 + maglim ) / 2 / (rvmax - rvmin )
199+ xpos = (xvmax * 0.85 + maglim ) / 2 / (xvmax - xvmin )
200200 if xpos <= 0.9 :
201201 plt .figtext (xpos , 0.7 , "x%.1f" % mag , backgroundcolor = "w" )
202202
203203 # Get a tight view
204- plt .xlim (rvmin , rvmax )
204+ plt .xlim (xvmin , xvmax )
205205 ymin = min (diff [sel ])
206- ymax = max (max (grdat [sel ]), max (gtemp [sel ]))
206+ ymax = max (max (fxdat [sel ]), max (ftemp [sel ]))
207207 yspan = ymax - ymin
208208 # Give a small border to the plot
209209 gap = 0.05 * yspan
@@ -306,38 +306,38 @@ def plot_param(target_labels, param_list, param_name=None, field=None):
306306 return
307307
308308
309- def truncate_func (r , gr , rmin = None , rmax = None ):
310- """Truncate a function g(r ) to specified bounds.
309+ def truncate_func (x , fx , xmin = None , xmax = None ):
310+ """Truncate a function f(x ) to specified bounds.
311311
312312 Parameters
313313 ----------
314- r
315- The r -values of the function g(r ).
316- gr
317- Function g(r ) values.
318- rmin
319- The minimum r -value. If this is None (default), the lower bound of
314+ x
315+ The x -values of the function f(x ).
316+ fx
317+ Function f(x ) values at each x-value .
318+ xmin
319+ The minimum x -value. If this is None (default), the lower bound of
320320 the function is not altered.
321- rmax
322- The maximum r -value. If this is None (default), the upper bound of
321+ xmax
322+ The maximum x -value. If this is None (default), the upper bound of
323323 the function is not altered.
324324
325325 Returns
326326 -------
327- r, gr
328- Returns the truncated r, gr .
327+ x, fx
328+ Returns the truncated x, fx .
329329 """
330330
331- if rmin is not None :
332- sel = r >= rmin
333- gr = gr [sel ]
334- r = r [sel ]
335- if rmax is not None :
336- sel = r <= rmax
337- gr = gr [sel ]
338- r = r [sel ]
331+ if xmin is not None :
332+ sel = x >= xmin
333+ fx = fx [sel ]
334+ x = x [sel ]
335+ if xmax is not None :
336+ sel = x <= xmax
337+ fx = fx [sel ]
338+ x = x [sel ]
339339
340- return r , gr
340+ return x , fx
341341
342342
343343def _find_offset (pairlist ):
0 commit comments