Skip to content

Commit f4940b8

Browse files
committed
Instituted matplotlib.pyplot syntax in place of pylab as suggested by official doc.
1 parent d6e0cf3 commit f4940b8

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

diffpy/pdfmorph/pdfplot.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
##############################################################################
1515
"""Collection of plotting functions for PDFs."""
1616

17-
import pylab
17+
import matplotlib.pyplot as plt
1818
import numpy
1919

2020
# FIXME - make this return the figure object in the future, so several views
@@ -45,20 +45,20 @@ def plotPDFs(pairlist, labels=None, offset ='auto', rmin = None, rmax = None):
4545
labels = list(labels)
4646
labels.extend([""] * gap)
4747

48-
#pylab.clf()
49-
#pylab.ioff()
48+
#plt.clf()
49+
#plt.ioff()
5050
for idx, pair in enumerate(pairlist):
5151
r, gr = pair
52-
pylab.plot(r, gr + idx * offset, label = labels[idx])
53-
pylab.xlim(rmin, rmax)
52+
plt.plot(r, gr + idx * offset, label = labels[idx])
53+
plt.xlim(rmin, rmax)
5454

5555
if gap == 0:
56-
pylab.legend(loc = 0)
56+
plt.legend(loc = 0)
5757

58-
pylab.xlabel("$r (\AA)$")
59-
pylab.ylabel("$G (\AA^{-1})$")
58+
plt.xlabel("$r (\AA)$")
59+
plt.ylabel("$G (\AA^{-1})$")
6060

61-
pylab.show()
61+
plt.show()
6262
return
6363

6464
def comparePDFs(pairlist, labels=None, rmin = None, rmax = None, show = True,
@@ -139,55 +139,55 @@ def comparePDFs(pairlist, labels=None, rmin = None, rmax = None, show = True,
139139
scale = min(1, max(scale, 0.8))
140140
figsize = [13.5, 4.5]
141141
figsize[0] *= scale
142-
fig = pylab.figure(1, figsize = figsize)
142+
fig = plt.figure(1, figsize = figsize)
143143
# Get the margins based on the figure size
144144
lm = 0.12 / scale
145145
bm = 0.20 / scale
146146
rm = 0.02 / scale
147147
tm = 0.15 / scale
148-
axes = pylab.Axes(fig, [lm, bm, 1 - lm - rm, 1 - bm - tm])
148+
axes = plt.Axes(fig, [lm, bm, 1 - lm - rm, 1 - bm - tm])
149149
fig.add_axes(axes)
150-
pylab.minorticks_on()
150+
plt.minorticks_on()
151151

152-
pylab.plot(rdat, grdat, label = labeldata, marker = 'o', markerfacecolor
152+
plt.plot(rdat, grdat, label = labeldata, marker = 'o', markerfacecolor
153153
= 'white', markeredgecolor = 'blue', markersize = 7,
154154
markeredgewidth = 0.75)
155-
pylab.plot(rfit, grfit, label = labelfit, linestyle = 'solid', linewidth =
155+
plt.plot(rfit, grfit, label = labelfit, linestyle = 'solid', linewidth =
156156
2, color = 'red')
157-
pylab.plot(rdat, offset*numpy.ones_like(diff), linestyle = '--', linewidth
157+
plt.plot(rdat, offset*numpy.ones_like(diff), linestyle = '--', linewidth
158158
= 1, color = 'black', dashes = (15, 15), aa = False)
159159
diff += offset
160-
pylab.plot(rdat, diff, label = labeldiff, linestyle = 'solid',
160+
plt.plot(rdat, diff, label = labeldiff, linestyle = 'solid',
161161
linewidth = 1.5, color = 'green')
162162

163163
if maglim is not None:
164164
# Add a line for the magnification cutoff
165-
pylab.axvline(maglim, 0, 1, linestyle = '--', color = 'black',
165+
plt.axvline(maglim, 0, 1, linestyle = '--', color = 'black',
166166
linewidth = 1.5, dashes = (14, 7))
167167
# FIXME - look for a place to put the maglim
168168
xpos = (rvmax*0.85 + maglim) / 2 / (rvmax - rvmin)
169169
if xpos <= 0.9:
170-
pylab.figtext(xpos, 0.7, "x%.1f"%mag, backgroundcolor='w')
170+
plt.figtext(xpos, 0.7, "x%.1f"%mag, backgroundcolor='w')
171171

172172
# Get a tight view
173-
pylab.xlim(rvmin, rvmax)
173+
plt.xlim(rvmin, rvmax)
174174
ymin = min(diff[sel])
175175
ymax = max(max(grdat[sel]), max(gtemp[sel]))
176176
yspan = ymax - ymin
177-
# Give a small boarder to the plot
177+
# Give a small border to the plot
178178
gap = 0.05 * yspan
179179
ymin -= gap
180180
ymax += gap
181-
pylab.ylim(ymin, ymax)
181+
plt.ylim(ymin, ymax)
182182

183183
# Make labels and legends
184-
pylab.xlabel("r $(\AA)$")
185-
pylab.ylabel("G $(\AA^{-1})$")
186-
#pylab.legend(loc = 0)
184+
plt.xlabel("r $(\AA)$")
185+
plt.ylabel("G $(\AA^{-1})$")
186+
#plt.legend(loc = 0)
187187
if legend:
188-
pylab.legend(bbox_to_anchor=(0.005, 1.02, 0.99, .10), loc=3,
188+
plt.legend(bbox_to_anchor=(0.005, 1.02, 0.99, .10), loc=3,
189189
ncol=3, mode="expand", borderaxespad=0)
190-
if show: pylab.show()
190+
if show: plt.show()
191191

192192
return
193193

@@ -217,17 +217,17 @@ def truncatePDFs(r, gr, rmin = None, rmax = None):
217217

218218
def _configure():
219219
"""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
220+
import matplotlib.pyplot as plt
221+
plt.rc("font", size = 40)
222+
plt.rc("axes", linewidth = 2, labelsize = 30)
223+
plt.rc("xtick", labelsize = 25)
224+
plt.rc("xtick.major", size = 7)
225+
plt.rc("xtick.minor", size = 3)
226+
plt.rc("ytick", labelsize = 25)
227+
plt.rc("ytick.major", size = 7)
228+
plt.rc("ytick.minor", size = 3)
229+
plt.rc("legend", fontsize = 18)
230+
plt.rc("lines", markeredgewidth = 2) # thicker axes and symbols
231231
return
232232

233233
def _findOffset(pairlist):

0 commit comments

Comments
 (0)