Skip to content

Commit 8e53e3e

Browse files
author
meihuisu
committed
Merge branch 'withAnaconda3' of github.com:SCECcode/ucvm_plotting into withAnaconda3
2 parents e81eb07 + 57427ea commit 8e53e3e

10 files changed

+22
-17
lines changed
198 Bytes
Binary file not shown.

dist/ucvm_plotting-0.0.6.tar.gz

-89.6 KB
Binary file not shown.

pycvm/cross_section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _plot_file(self) :
275275
self.getplotvals(mproperty)
276276

277277
# Call the plot object.
278-
p = Plot(None, None, None, None, 10, 10)
278+
p = Plot(False, None, None, None, None, 10, 10)
279279

280280
plt.axes([0.1,0.7,0.8,0.25])
281281

pycvm/cvm_plot.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,23 @@ class Plot:
5454
# Initializes the Plot with a set of basic parameters. Use the
5555
# addsubplot() method to add a sub-plot to the plot.
5656
#
57+
# @param subplots The plot can contain subplots
5758
# @param title The title for the plot.
5859
# @param xlabel The label to be displayed on the x-axis.
5960
# @param ylabel The label for the y-axis.
6061
# @param legend A legend to be displayed on the lower left of the plot.
6162
# @param width The width of the plot in inches (dpi = 100).
6263
# @param height The height of the plot in inches (dpi = 100).
63-
def __init__(self, title = None, xlabel = None, ylabel = None, legend = None, width = 10, height = 10):
64+
def __init__(self, subplots = True, title = None, xlabel = None, ylabel = None, legend = None, width = 10, height = 10):
6465
## Defines the figure and plot object to which we can add subplots.
6566

66-
self.figure = plt.figure(figsize=(width, height), dpi=100)
67-
self.plot = None
67+
## For depth profile with subplots
68+
if subplots :
69+
self.figure, self.axs = plt.subplots(figsize=(width, height), dpi=100)
70+
else :
71+
## For cross section/horizontal slice -- no subplots
72+
self.figure = plt.figure(figsize=(width, height), dpi=100)
73+
self.axs = None
6874

6975
if ylabel != None:
7076
plt.ylabel(ylabel, fontsize=14)
@@ -86,12 +92,12 @@ def __init__(self, title = None, xlabel = None, ylabel = None, legend = None, wi
8692
#
8793
# @return The subplot that has been added to the already generated plot.
8894
def addsubplot(self):
89-
if(self.plot == None) :
90-
self.plot = self.figure.add_subplot(1, 1, 1)
91-
self.subplotcounter = 1
95+
if(self.axs == None) :
96+
print("ERROR: PLOT is not setup to take subplots.")
97+
exit(1)
9298
else:
9399
self.subplotcounter += 1;
94-
return self.plot;
100+
return self.axs;
95101

96102
##
97103
# Shows the plot.

pycvm/depth_profile.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ def addtoplot(self, plot, colors = None, customlabels = None):
235235
max_x = max(max_x, max(newvplist))
236236
plot.addsubplot().plot(newvplist, yvals, "-", color=vpcolor, label=vplabel)
237237

238-
239238
if "vs" in self.properties:
240239
myInt=1000
241240
newvslist=np.array(self.vslist)/myInt
@@ -307,11 +306,11 @@ def _plot_file(self):
307306
title = "%s%s Depth Profile From %sm To %sm at (%.6f,%.6f)" % (location_text, cvmdesc, self.startingpoint.depth, self.todepth, self.startingpoint.longitude, self.startingpoint.latitude)
308307

309308
# Call the plot object.
310-
p = Plot(title, "Units (see legend)", "Depth (m)", None, 7, 10)
309+
p = Plot(True, title, "Units (see legend)", "Depth (m)", None, 7, 10)
311310

312311
# Add to plot.
313312
self.addtoplot(p)
314-
313+
315314
if self.filename == None:
316315
plt.show()
317316
else:

pycvm/difference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def plot(self, property, filename = None, title = None):
8585
title = "Horizontal Slice Difference Plot"
8686

8787
# Call the plot object.
88-
p = Plot(title, "", "", None, 10, 10)
88+
p = Plot(False,title, "", "", None, 10, 10)
8989

9090
colormap = basemap.cm.GMT_seis
9191

@@ -137,7 +137,7 @@ def plot(self, property, filename = None, title = None):
137137
title = "Horizontal Slice Difference Plot"
138138

139139
# Call the plot object.
140-
p = Plot(None, None, None, None, 10, 10)
140+
p = Plot(False,None, None, None, None, 10, 10)
141141

142142
colormap = basemap.cm.GMT_seis
143143

pycvm/elevation_cross_section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def plot(self) :
241241
self.getplotvals(mproperty)
242242

243243
# Call the plot object.
244-
p = Plot(None, None, None, None, 10, 10)
244+
p = Plot(False,None, None, None, None, 10, 10)
245245

246246
plt.axes([0.1,0.7,0.8,0.25])
247247

pycvm/elevation_horizontal_slice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def plot(self, horizontal_label = None):
218218
self.getplotvals(mproperty)
219219

220220
# Call the plot object.
221-
p = Plot(title, "", "", None, 10, 10)
221+
p = Plot(False,title, "", "", None, 10, 10)
222222

223223
u = UCVM(install_dir=self.installdir, config_file=self.configfile)
224224

pycvm/elevation_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def _plot_file(self):
297297
title = "%s%s Elevation Profile From %sm To %sm at (%.2f,%.2f)" % (location_text, cvmdesc, self.startelevation, self.toelevation, self.startingpoint.longitude, self.startingpoint.latitude)
298298

299299
# Call the plot object.
300-
p = Plot(title, "Units (see legend)", "Elevation (m)", None, 7, 10)
300+
p = Plot(True,title, "Units (see legend)", "Elevation (m)", None, 7, 10)
301301

302302
# Add to plot.
303303
self.addtoplot(p)

pycvm/horizontal_slice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def _plot_file(self, horizontal_label = None):
257257
self.getplotvals(mproperty)
258258

259259
# Call the plot object.
260-
p = Plot(self.title, "", "", None, 10, 10)
260+
p = Plot(False,self.title, "", "", None, 10, 10)
261261

262262
ucvm = self.ucvm
263263
# UCVM(install_dir=self.installdir, config_file=self.configfile)

0 commit comments

Comments
 (0)