Skip to content
Snippets Groups Projects
Commit b2ea4106 authored by Blaise Li's avatar Blaise Li
Browse files

Further forward violin plot kwargs.

parent 14de21d2
No related branches found
No related tags found
No related merge requests found
......@@ -1230,7 +1230,7 @@ def violin_usage_vertical(
def violin_usage_by_clusters(usage_with_clusters, aa, # pylint: disable=C0103
ylabel_template,
cluster_level_template="cluster_{aa}",
vertical=False):
vertical=False, **violin_kwargs):
"""
Plot a series of violin plots for each cluster of genes.
......@@ -1252,16 +1252,18 @@ def violin_usage_by_clusters(usage_with_clusters, aa, # pylint: disable=C0103
nrows=clusters.ngroups,
figsize=(18, 6 * clusters.ngroups))
for ((cluster, usage_table), axis) in zip(clusters, axes):
kwargs = {"axis": axis}
kwargs.update(violin_kwargs)
if vertical:
violin_usage_vertical(
usage_table, "codon",
ylabel_template.format(aa=aa, cluster=cluster),
axis=axis)
**kwargs)
else:
violin_usage(
usage_table, "codon",
ylabel_template.format(aa=aa, cluster=cluster),
axis=axis)
**kwargs)
# Based on
......@@ -1280,7 +1282,7 @@ def adjacent_values(q0, q1, q3, q4): # pylint: disable=C0103
def violin_with_thresh(data, thresh, ylabel,
facecolor="grey", axis=None):
facecolor="grey", axis=None, **violin_kwargs):
"""
Draw a violin plot from *data* with a horizontal line at value *thresh*.
......@@ -1291,7 +1293,9 @@ def violin_with_thresh(data, thresh, ylabel,
"""
if axis is None:
_, axis = plt.subplots(figsize=(2, 3.5))
violin_parts = axis.violinplot(data, showextrema=False)
kwargs = {"showextrema": False}
kwargs.update(violin_kwargs)
violin_parts = axis.violinplot(data, **kwargs)
# https://stackoverflow.com/a/26291582/1878788
[body] = violin_parts["bodies"]
body.set_facecolor(facecolor)
......
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