Skip to content
Snippets Groups Projects
Commit a9f79b98 authored by ChiWai Chan's avatar ChiWai Chan
Browse files

horizon.py: add limits and title options for horizon distance plots.

parent ab933df4
No related branches found
No related tags found
No related merge requests found
...@@ -133,7 +133,7 @@ class HorizonDistance: ...@@ -133,7 +133,7 @@ class HorizonDistance:
raise UnknownExtensionError("Cannot determine the extension of the input data sources, please prepare files with the following extension: ('.gz' or '.cache').") raise UnknownExtensionError("Cannot determine the extension of the input data sources, please prepare files with the following extension: ('.gz' or '.cache').")
def savefig(self, output, figsize=(12,4)): def savefig(self, output, figsize=(12,4), limits=None, title=None):
"""Save the horizon distance plot to disk. """Save the horizon distance plot to disk.
Args: Args:
...@@ -142,11 +142,18 @@ class HorizonDistance: ...@@ -142,11 +142,18 @@ class HorizonDistance:
figsize: figsize:
tuple of float, default (12,4), set the output tuple of float, default (12,4), set the output
figure size in inch. figure size in inch.
limits:
list of float, default to auto detection, set
the limits on horizon distance.
title:
str, the title of the plots.
Returns: Returns:
None None
""" """
fig, ax = pyplot.subplots(1, 2, figsize = figsize) fig, ax = pyplot.subplots(1, 2, figsize = figsize)
if title is not None:
fig.suptitle(title)
pyplot.tight_layout(pad = 4, w_pad = 4, h_pad = 4) pyplot.tight_layout(pad = 4, w_pad = 4, h_pad = 4)
mint = int(min([min(horizon_history.keys()) for _, horizon_history in self.horizon_history_dict.items()])) mint = int(min([min(horizon_history.keys()) for _, horizon_history in self.horizon_history_dict.items()]))
...@@ -162,6 +169,9 @@ class HorizonDistance: ...@@ -162,6 +169,9 @@ class HorizonDistance:
ax[0].semilogy(SinceGPSTime, horizon_dist, "x", color = plotutil.colour_from_instruments([ifo]), label = ifo) ax[0].semilogy(SinceGPSTime, horizon_dist, "x", color = plotutil.colour_from_instruments([ifo]), label = ifo)
ax[1].hist(horizon_dist, binvec, alpha = 0.5, color = plotutil.colour_from_instruments([ifo]), label = ifo) ax[1].hist(horizon_dist, binvec, alpha = 0.5, color = plotutil.colour_from_instruments([ifo]), label = ifo)
if limits is not None:
ax[0].set_ylim(limits)
ax[1].set_xlim(limits)
if self.verbose: if self.verbose:
sys.stderr.write("plotting " + str(output) + "\n") sys.stderr.write("plotting " + str(output) + "\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment