|
14 | 14 | ##############################################################################
|
15 | 15 | """Collection of plotting functions for PDFs."""
|
16 | 16 |
|
17 |
| -import pylab |
| 17 | +import matplotlib.pyplot as plt |
18 | 18 | import numpy
|
19 | 19 |
|
20 | 20 | # FIXME - make this return the figure object in the future, so several views
|
@@ -45,20 +45,19 @@ def plotPDFs(pairlist, labels=None, offset ='auto', rmin = None, rmax = None):
|
45 | 45 | labels = list(labels)
|
46 | 46 | labels.extend([""] * gap)
|
47 | 47 |
|
48 |
| - #pylab.clf() |
49 |
| - #pylab.ioff() |
50 | 48 | for idx, pair in enumerate(pairlist):
|
51 | 49 | r, gr = pair
|
52 |
| - pylab.plot(r, gr + idx * offset, label = labels[idx]) |
53 |
| - pylab.xlim(rmin, rmax) |
| 50 | + plt.plot(r, gr + idx * offset, label = labels[idx]) |
| 51 | + plt.xlim(rmin, rmax) |
54 | 52 |
|
55 | 53 | if gap == 0:
|
56 |
| - pylab.legend(loc = 0) |
| 54 | + plt.legend(loc = 0) |
57 | 55 |
|
58 |
| - pylab.xlabel("$r (\AA)$") |
59 |
| - pylab.ylabel("$G (\AA^{-1})$") |
60 | 56 |
|
61 |
| - pylab.show() |
| 57 | + plt.xlabel("$r \mathrm{\AA}$") |
| 58 | + plt.ylabel("$G \mathrm{\AA}^{-1}$") |
| 59 | + |
| 60 | + plt.show() |
62 | 61 | return
|
63 | 62 |
|
64 | 63 | def comparePDFs(pairlist, labels=None, rmin = None, rmax = None, show = True,
|
@@ -139,55 +138,54 @@ def comparePDFs(pairlist, labels=None, rmin = None, rmax = None, show = True,
|
139 | 138 | scale = min(1, max(scale, 0.8))
|
140 | 139 | figsize = [13.5, 4.5]
|
141 | 140 | figsize[0] *= scale
|
142 |
| - fig = pylab.figure(1, figsize = figsize) |
| 141 | + fig = plt.figure(1, figsize = figsize) |
143 | 142 | # Get the margins based on the figure size
|
144 | 143 | lm = 0.12 / scale
|
145 | 144 | bm = 0.20 / scale
|
146 | 145 | rm = 0.02 / scale
|
147 | 146 | tm = 0.15 / scale
|
148 |
| - axes = pylab.Axes(fig, [lm, bm, 1 - lm - rm, 1 - bm - tm]) |
| 147 | + axes = plt.Axes(fig, [lm, bm, 1 - lm - rm, 1 - bm - tm]) |
149 | 148 | fig.add_axes(axes)
|
150 |
| - pylab.minorticks_on() |
| 149 | + plt.minorticks_on() |
151 | 150 |
|
152 |
| - pylab.plot(rdat, grdat, label = labeldata, marker = 'o', markerfacecolor |
| 151 | + plt.plot(rdat, grdat, label = labeldata, marker = 'o', markerfacecolor |
153 | 152 | = 'white', markeredgecolor = 'blue', markersize = 7,
|
154 | 153 | markeredgewidth = 0.75)
|
155 |
| - pylab.plot(rfit, grfit, label = labelfit, linestyle = 'solid', linewidth = |
| 154 | + plt.plot(rfit, grfit, label = labelfit, linestyle = 'solid', linewidth = |
156 | 155 | 2, color = 'red')
|
157 |
| - pylab.plot(rdat, offset*numpy.ones_like(diff), linestyle = '--', linewidth |
| 156 | + plt.plot(rdat, offset*numpy.ones_like(diff), linestyle = '--', linewidth |
158 | 157 | = 1, color = 'black', dashes = (15, 15), aa = False)
|
159 | 158 | diff += offset
|
160 |
| - pylab.plot(rdat, diff, label = labeldiff, linestyle = 'solid', |
| 159 | + plt.plot(rdat, diff, label = labeldiff, linestyle = 'solid', |
161 | 160 | linewidth = 1.5, color = 'green')
|
162 | 161 |
|
163 | 162 | if maglim is not None:
|
164 | 163 | # Add a line for the magnification cutoff
|
165 |
| - pylab.axvline(maglim, 0, 1, linestyle = '--', color = 'black', |
| 164 | + plt.axvline(maglim, 0, 1, linestyle = '--', color = 'black', |
166 | 165 | linewidth = 1.5, dashes = (14, 7))
|
167 | 166 | # FIXME - look for a place to put the maglim
|
168 | 167 | xpos = (rvmax*0.85 + maglim) / 2 / (rvmax - rvmin)
|
169 | 168 | if xpos <= 0.9:
|
170 |
| - pylab.figtext(xpos, 0.7, "x%.1f"%mag, backgroundcolor='w') |
| 169 | + plt.figtext(xpos, 0.7, "x%.1f"%mag, backgroundcolor='w') |
171 | 170 |
|
172 | 171 | # Get a tight view
|
173 |
| - pylab.xlim(rvmin, rvmax) |
| 172 | + plt.xlim(rvmin, rvmax) |
174 | 173 | ymin = min(diff[sel])
|
175 | 174 | ymax = max(max(grdat[sel]), max(gtemp[sel]))
|
176 | 175 | yspan = ymax - ymin
|
177 |
| - # Give a small boarder to the plot |
| 176 | + # Give a small border to the plot |
178 | 177 | gap = 0.05 * yspan
|
179 | 178 | ymin -= gap
|
180 | 179 | ymax += gap
|
181 |
| - pylab.ylim(ymin, ymax) |
| 180 | + plt.ylim(ymin, ymax) |
182 | 181 |
|
183 | 182 | # Make labels and legends
|
184 |
| - pylab.xlabel("r $(\AA)$") |
185 |
| - pylab.ylabel("G $(\AA^{-1})$") |
186 |
| - #pylab.legend(loc = 0) |
| 183 | + plt.xlabel("r $\mathrm{\AA}$") |
| 184 | + plt.ylabel("G $(\mathrm{\AA}^{-1})$") |
187 | 185 | if legend:
|
188 |
| - pylab.legend(bbox_to_anchor=(0.005, 1.02, 0.99, .10), loc=3, |
| 186 | + plt.legend(bbox_to_anchor=(0.005, 1.02, 0.99, .10), loc=3, |
189 | 187 | ncol=3, mode="expand", borderaxespad=0)
|
190 |
| - if show: pylab.show() |
| 188 | + if show: plt.show() |
191 | 189 |
|
192 | 190 | return
|
193 | 191 |
|
@@ -217,17 +215,17 @@ def truncatePDFs(r, gr, rmin = None, rmax = None):
|
217 | 215 |
|
218 | 216 | def _configure():
|
219 | 217 | """Configure look and feel."""
|
220 |
| - import pylab |
221 |
| - pylab.rc("font", size = 40) |
222 |
| - pylab.rc("axes", linewidth = 2, labelsize = 30) |
223 |
| - pylab.rc("xtick", labelsize = 25) |
224 |
| - pylab.rc("xtick.major", size = 7) |
225 |
| - pylab.rc("xtick.minor", size = 3) |
226 |
| - pylab.rc("ytick", labelsize = 25) |
227 |
| - pylab.rc("ytick.major", size = 7) |
228 |
| - pylab.rc("ytick.minor", size = 3) |
229 |
| - pylab.rc("legend", fontsize = 18) |
230 |
| - pylab.rc("lines", markeredgewidth = 2) # thicker axes and symbols |
| 218 | + import matplotlib.pyplot as plt |
| 219 | + plt.rc("font", size = 40) |
| 220 | + plt.rc("axes", linewidth = 2, labelsize = 30) |
| 221 | + plt.rc("xtick", labelsize = 25) |
| 222 | + plt.rc("xtick.major", size = 7) |
| 223 | + plt.rc("xtick.minor", size = 3) |
| 224 | + plt.rc("ytick", labelsize = 25) |
| 225 | + plt.rc("ytick.major", size = 7) |
| 226 | + plt.rc("ytick.minor", size = 3) |
| 227 | + plt.rc("legend", fontsize = 18) |
| 228 | + plt.rc("lines", markeredgewidth = 2) # thicker axes and symbols |
231 | 229 | return
|
232 | 230 |
|
233 | 231 | def _findOffset(pairlist):
|
|
0 commit comments