- changed status to closed
standardize plotting API
Issue #23
closed
latest-generation plotting functions all contain the following boilerplate:
# honor ax
if ax is not None:
plt.sca(ax)
# clear figure if plotting in `outfile` mode
if outfile is not None:
plt.clf()
# prepare sns
sns.set(color_codes=True)
sns.set_style('ticks')
<actual plotting steps>
# save figure
if outfile is not None:
check_outdir(outfile)
if plot_kwargs:
adjust_plot(**plot_kwargs)
plt.savefig(outfile, bbox_inches='tight')
return plt.gca()
it sounds like we could just write a decorator to do all of this
clients of the decorator could write
@plotter
def plot_whatever(data, **kwargs):
plt.scatter(data[0], data[1])
and clients of the decorated function could make calls like
plot_whatever([x, y], ax=special_ax)
plot_whatever([x, y], outfile='whatever.png')
plot_whatever([x, y], xlabel='whatever')
the decorator would first check
ax = kwargs.get('ax')
outfile = kwargs.get('ax')
plot_kwargs = {key: kwargs.get(key) for key in inspect.getargspec(adjust_plot)[0]}
this would immediately fix the "plotters" half of #9
it would also fix #22
Comments (1)
-
reporter - Log in to comment
major overhaul of counts/primermap parsing and plotting API
plotting API is now formalized in a new decorator:
@lib5c.util.plotting.plotter
most plotters now follow this API, except for the old heatmap plotters and cluster heatmap plotters, as well as legacy plotters
primermap/counts parsing is now standardized in line with modules2016: only two functions are supported:
load_primermap()
andload_counts()
all tools have been updated to reflect this change
lib5c.tools.helpers.resolve_level()
has been broken up intolib5c.tools.helpers.resolve_level()
andlib5c.tools.helpers.resolve_primerfile()
- this helper is only needed in a small number of toolslib5c.tools.parents.level_parser
has been broken up intolib5c.tools.parents.level_parser
andlib5c.tools.parents.primerfile_parser
-level_parser
is used rarely whileprimerfile_parser
is ubiquitousthis closes
#23, closes#21, closes#18, closes#22, closes#11, and closes#9→ <<cset f4e899afa042>>