Commit 084f5022 authored by Blaise Li's avatar Blaise Li
Browse files

Fixing tex issues in some plots.

parent ba8352b8
from functools import reduce
from re import sub
import warnings
......@@ -323,6 +324,10 @@ def plot_norm_correlations(correlations):
#correlations.plot.kde(ax=ax1)
#sns.violinplot(data=correlations, orient="h", ax=ax2)
#ax2.set_xlabel("Pearson correlation coefficient")
usetex = mpl.rcParams.get("text.usetex", False)
if usetex:
correlations.columns = [sub(
"_", "\_", colname) for colname in correlations.columns]
axis = sns.violinplot(data=correlations, cut=0)
axis.set_ylabel("Pearson correlation coefficient")
......@@ -332,6 +337,10 @@ def plot_counts_distribution(data, xlabel):
#axis = data.plot.kde(legend=None)
#axis.set_xlabel(xlabel)
#axis.legend(ncol=len(REPS))
usetex = mpl.rcParams.get("text.usetex", False)
if usetex:
xlabel = sub("_", r"\_", xlabel)
data.columns = [sub("_", "\_", colname) for colname in data.columns]
try:
axis = data.plot.kde()
except ValueError as e:
......@@ -346,6 +355,10 @@ def plot_counts_distribution(data, xlabel):
def plot_boxplots(data, ylabel):
fig = plt.figure(figsize=(6, 12))
axis = fig.add_subplot(111)
usetex = mpl.rcParams.get("text.usetex", False)
if usetex:
ylabel = sub("_", r"\_", ylabel)
data.columns = [sub("_", "\_", colname) for colname in data.columns]
data.plot.box(ax=axis)
axis.set_ylabel(ylabel)
for label in axis.get_xticklabels():
......@@ -411,6 +424,9 @@ def plot_lfc_distribution(res, contrast, fold_type=None):
fold_type = "log2FoldChange"
lfc = getattr(res, fold_type).dropna()
lfc.name = contrast
usetex = mpl.rcParams.get("text.usetex", False)
if usetex:
lfc.columns = [sub("_", "\_", colname) for colname in lfc.columns]
axis = sns.kdeplot(lfc)
axis.set_xlabel(fold_type)
axis.set_ylabel("frequency")
......@@ -561,6 +577,10 @@ def plot_paired_scatters(data, columns=None, hue=None, log_log=False):
"""Alternative to pairplot, in order to avoid histograms on the diagonal."""
if columns is None:
columns = data.columns
usetex = mpl.rcParams.get("text.usetex", False)
if usetex:
data.columns = [sub("_", "\_", colname) for colname in data.columns]
columns = [sub("_", "\_", colname) for colname in columns]
g = sns.PairGrid(data, vars=columns, hue=hue, size=8)
#g.map_offdiag(plt.scatter, marker=".")
g.map_lower(plt.scatter, marker=".")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment