[edit] docstring added and returning the figure instead of showing the plot

additionally hide_labels is now defined only once before going into the loop
This commit is contained in:
Sebastian Wehling-Benatelli 2016-05-11 09:49:19 +02:00
parent 63ac0107d0
commit f8807a7ea6

View File

@ -269,6 +269,13 @@ class PDFDictionary(object):
return pdf_picks return pdf_picks
def plot(self, stations=None): def plot(self, stations=None):
'''
plots the all probability density function for either desired STATIONS
or all available date
:param stations: list of stations to be plotted
:type stations: list
:return: matplotlib figure object containing the plot
'''
assert stations is not None or not isinstance(stations, list), \ assert stations is not None or not isinstance(stations, list), \
'parameter stations should be a list not {0}'.format(type(stations)) 'parameter stations should be a list not {0}'.format(type(stations))
if not stations: if not stations:
@ -279,12 +286,12 @@ class PDFDictionary(object):
istations = range(nstations) istations = range(nstations)
fig, axarr = plt.subplots(nstations, 2, sharex='col', sharey='row') fig, axarr = plt.subplots(nstations, 2, sharex='col', sharey='row')
hide_labels = True
for n in istations: for n in istations:
station = stations[n] station = stations[n]
pdfs = self.pdf_data[station] pdfs = self.pdf_data[station]
for l, phase in enumerate(pdfs.keys()): for l, phase in enumerate(pdfs.keys()):
hide_labels = True
try: try:
axarr[n, l].plot(pdfs[phase].axis, pdfs[phase].data) axarr[n, l].plot(pdfs[phase].axis, pdfs[phase].data)
if n is 0: if n is 0:
@ -314,4 +321,4 @@ class PDFDictionary(object):
plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False) plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False)
plt.setp([a.get_yticklabels() for a in axarr[:, 0]], visible=False) plt.setp([a.get_yticklabels() for a in axarr[:, 0]], visible=False)
plt.show() return fig