Skip to content

Commit

Permalink
Added textwrapping and fixed measurement cols
Browse files Browse the repository at this point in the history
  • Loading branch information
wflynny committed Jul 21, 2020
1 parent 0ba310e commit 627030b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions post_processing/plate_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import cmocean
from pathlib import Path
from datetime import datetime
import textwrap

import utils

plt.rcParams["xtick.major.pad"] = 0



def wrap(text, width=30):
return "\n".join(textwrap.wrap(text, width=width))


def add_timestamp(fig):
Expand Down Expand Up @@ -111,11 +113,11 @@ def plot_tri_data(

if lower_cbar_ax is not None:
ax.figure.colorbar(hm_lower, cax=lower_cbar_ax)
lower_cbar_ax.set_ylabel(lower_name)
lower_cbar_ax.set_ylabel(wrap(lower_name))
lower_cbar_ax.yaxis.set_label_position("left")
if upper_cbar_ax is not None:
ax.figure.colorbar(hm_upper, cax=upper_cbar_ax)
upper_cbar_ax.set_ylabel(upper_name)
upper_cbar_ax.set_ylabel(wrap(upper_name))
upper_cbar_ax.yaxis.set_label_position("left")


Expand Down Expand Up @@ -151,7 +153,7 @@ def plot_plate_data(ax, data, cmap_or_palette, vmin=1e-6, cbar_ax=None, log=Fals
tl.set_position((x, y+0.06))

if cbar_ax is not None:
cbar_ax.set_ylabel(data_name)
cbar_ax.set_ylabel(wrap(data_name, width=30))
cbar_ax.yaxis.set_label_position("left")


Expand All @@ -175,7 +177,7 @@ def plot_categorical_annotation(ax, data, palette):
ax.set_yticks(legend_data.flatten())
ax.set_yticklabels(labels)
ax.yaxis.tick_right()
ax.set_ylabel(data_name)
ax.set_ylabel(wrap(data_name))
ax.yaxis.set_label_position("left")


Expand Down Expand Up @@ -268,7 +270,7 @@ def plot_randomization(data):
return fig


def plot_measurements(data, ncols=4, measurement_cols=None):
def plot_measurements(data, ncols=2, measurement_cols=None):
data = data.loc[~data.index.duplicated(), :]
if measurement_cols is None:
nonmeasurement_cols = pd.Index((
Expand All @@ -287,7 +289,7 @@ def plot_measurements(data, ncols=4, measurement_cols=None):
for plate, col in zip(plates, measurement_cols):
ax, anno1, anno2 = plate
dmin, dmax = data[col].min(), data[col].max()
log = np.log10(dmax/dmin) > 3
log = dmax-dmin > 1000
plot_plate_data(ax, data[col], "cmo.oxy", cbar_ax=anno1, log=log)
if anno2 is not None:
anno2.set_axis_off()
Expand Down

0 comments on commit 627030b

Please sign in to comment.