diff --git a/libcodonusage/__init__.py b/libcodonusage/__init__.py index 4241c507bd3127ebcfcaed45519d8030c91371e3..8d68210b1570b3050c1a22f2523baf274e77a9a8 100644 --- a/libcodonusage/__init__.py +++ b/libcodonusage/__init__.py @@ -1,6 +1,6 @@ __copyright__ = "Copyright (C) 2022 Blaise Li" __licence__ = "GNU GPLv3" -__version__ = "0.23" +__version__ = "0.24" from .libcodonusage import ( aa2colour, aa_usage, diff --git a/libcodonusage/libcodonusage.py b/libcodonusage/libcodonusage.py index c675e92d77b3953861902607b2bf89ba658dd632..70da58fc2aa5234ad6c33f2b20504c4bea105b64 100644 --- a/libcodonusage/libcodonusage.py +++ b/libcodonusage/libcodonusage.py @@ -1333,16 +1333,13 @@ def violin_usage( "data": long_form, "ax": axis, "orient": "v", "scale": "count"} kwargs.update(violin_kwargs) axis = sns.violinplot(**kwargs) - # sns.violinplot(x=variable, y=ylabel, order=variable2order(variable), - # hue=hue, palette=palette, dodge=dodge, - # data=long_form, ax=axis, orient="v", scale="count", - # **violin_kwargs) if do_legend: plt.legend(bbox_to_anchor=(1.01, 1), borderaxespad=0) if variable == "codon": ticklabels = format_codon_labels(axis.get_xticklabels()) else: ticklabels = axis.get_xticklabels() + # TODO: Expect issues when variable == "aa" axis.set_xticklabels(ticklabels, rotation=90) return axis @@ -1365,7 +1362,13 @@ def violin_usage_vertical( nb_violins = len(usage_table.index.get_level_values(hue).unique()) long_form = to_long_form(usage_table, ylabel, others=[hue]) if axis is None: - _, axis = plt.subplots(figsize=(6, 44 * nb_violins)) + if variable == "codon": + base_height = 44 + elif variable == "aa": + base_height = 18 + else: + raise NotImplementedError(f"Unsupported variable: {variable}.") + _, axis = plt.subplots(figsize=(6, base_height * nb_violins)) if hue == "aa": palette = aa2colour else: @@ -1377,16 +1380,9 @@ def violin_usage_vertical( "data": long_form, "ax": axis, "orient": "h", "scale": "count"} kwargs.update(violin_kwargs) axis = sns.violinplot(**kwargs) - # sns.violinplot( - # y=variable, x=ylabel, order=variable2order(variable), - # hue=hue, palette=palette, dodge=dodge, - # data=long_form, ax=axis, orient="h", scale="count", - # **violin_kwargs) if variable == "codon": ticklabels = format_codon_labels(axis.get_yticklabels()) - else: - ticklabels = axis.get_xticklabels() - axis.set_yticklabels(ticklabels) + axis.set_yticklabels(ticklabels) return axis