Skip to content

Commit fa828ec

Browse files
committed
Some small tweaks to the code for Plot and PlotLayout.
1 parent ae6c0ea commit fa828ec

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

Plot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ def save(self, filename, **kwargs):
347347
layout.save(filename,**kwargs)
348348

349349
def subplot(self, fig, row, column, position, projection):
350-
ax = fig.add_subplot(row, column, position, projection=projection)
350+
kwdict = {}
351+
352+
if projection is not None:
353+
kwdict["projection"] = projection
354+
355+
ax = fig.add_subplot(row, column, position, **kwdict)
351356
return self.drawPlot(fig, ax)
352357

353358
def drawPlot(self, fig, ax):

PlotLayout.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ def _doPlot(self):
182182
myCols = numPlots
183183
myPos = (currentRow * numPlots) + currentColumn
184184

185-
(currPlotHandles, currPlotLabels) = plot.subplot(
186-
fig, myRows, myCols, myPos, projection=plot.projection)
185+
(currPlotHandles, currPlotLabels) = self._plot_subplot(
186+
plot = plot, fig = fig, rows = myRows, cols = myCols,
187+
pos = myPos, projection=plot.projection)
187188

188189
for i in xrange(len(currPlotHandles)):
189190
if currPlotLabels[i] in plotLabels:
@@ -196,9 +197,6 @@ def _doPlot(self):
196197

197198
plotLabels.append(currPlotLabels[i])
198199

199-
# plotHandles.extend(currPlotHandles)
200-
# plotLabels.extend(currPlotLabels)
201-
202200
currentColumn += 1
203201
currentRow += 1
204202

@@ -214,8 +212,10 @@ def _doPlot(self):
214212
myCols = numColumns
215213
myPos = (currentRow * numColumns) + currentColumn
216214

217-
(currPlotHandles, currPlotLabels) = plot.subplot(
218-
fig, myRows, myCols, myPos, projection=plot.projection)
215+
(currPlotHandles, currPlotLabels) = self._plot_subplot(
216+
plot = plot, fig = fig, rows = myRows, cols = myCols,
217+
pos = myPos, projection=plot.projection)
218+
219219
for i in xrange(len(currPlotHandles)):
220220
if currPlotLabels[i] in plotLabels:
221221
continue
@@ -239,11 +239,7 @@ def _doPlot(self):
239239
figLegendKeywords = {}
240240

241241
if self.figLegendCols is not None:
242-
versionPieces = [int(x) for x in matplotlib.__version__.split('.')]
243-
244-
(superMajor, major, minor) = versionPieces[0:3]
245-
246-
if superMajor == 0 and major < 98:
242+
if not self._check_min_matplotlib_version((0, 98, 0)):
247243
warnings.warn("Number of columns support not available in "
248244
"versions of matplotlib prior to 0.98")
249245
else:
@@ -266,6 +262,18 @@ def _doPlot(self):
266262

267263
return fig
268264

265+
def _plot_subplot(self, plot, fig, rows, cols, pos, projection):
266+
return plot.subplot(fig, rows, cols, pos, projection)
267+
268+
def _check_min_matplotlib_version(self, version):
269+
versionPieces = [int(x) for x in matplotlib.__version__.split('.')]
270+
271+
(superMajor, major, minor) = versionPieces[0:3]
272+
273+
minVersionSatisfied = (superMajor >= version[0] and major >= version[1]
274+
and minor >= version[2])
275+
return minVersionSatisfied
276+
269277
def plot(self):
270278
fig = self._doPlot()
271279
if not pylab.isinteractive():

0 commit comments

Comments
 (0)