Skip to content

Commit

Permalink
rename style_axis to style_plot and the color 'lightgrey' to 'gray'
Browse files Browse the repository at this point in the history
  • Loading branch information
keithchev committed Jul 1, 2024
1 parent 0f33d1e commit b8564b5
Show file tree
Hide file tree
Showing 11 changed files with 797 additions and 790 deletions.
2 changes: 1 addition & 1 deletion arcadia_pycolor/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
shell = HexCode("shell", "#EDE0D6")

# Neutral colors
lightgrey = HexCode("lightgrey", "#EBEDE8")
gray = HexCode("gray", "#EBEDE8")
chateau = HexCode("chateau", "#BAB0A8")
bark = HexCode("bark", "#8F8885")
slate = HexCode("slate", "#43413F")
Expand Down
4 changes: 2 additions & 2 deletions arcadia_pycolor/mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def set_colorbar_ticklabel_monospaced(axis: Union[Axes, None] = None):
set_ticklabel_monospaced(axis=cbar.ax)


def style_axis(
def style_plot(
axis: Union[Axes, None] = None,
monospaced_axes: Literal["x", "y", "both", None] = None,
categorical_axes: Literal["x", "y", "both", None] = None,
Expand Down Expand Up @@ -351,7 +351,7 @@ def add_legend_line(legend: Legend, linewidth: float = LEGEND_SEPARATOR_LINEWIDT

# Check that we haven't already put a drawing area within the legend.
# This should catch if we've already added the legend line
# through a different call to this function, e.g. calling "style_axis".
# through a different call to this function, e.g. calling "style_plot".
# This won't catch if the DrawingArea is added by a user otherwise,
# but most users shouldn't be adding new DrawingAreas to the legend.
if not isinstance(entries[0], DrawingArea):
Expand Down
2 changes: 1 addition & 1 deletion arcadia_pycolor/palettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
neutral = Palette(
"Neutral",
[
colors.lightgrey,
colors.gray,
colors.chateau,
colors.bark,
colors.slate,
Expand Down
12 changes: 6 additions & 6 deletions arcadia_pycolor/tests/plotting/test_barplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def plot_vertical_barplot_with_matplotlib_with_error_bars(ax):
"""
sample_ids = _word_wrap_sample_ids(BARPLOT_SAMPLE_IDS)
plt.bar(sample_ids, BARPLOT_NUM_READS, color=apc.aster)
apc.mpl.style_axis(ax, monospaced_axes="y")
apc.mpl.style_plot(ax, monospaced_axes="y")
apc.mpl.set_xaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_yaxis())

Expand All @@ -82,7 +82,7 @@ def plot_horizontal_barplot_with_matplotlib_with_error_bars(ax):
This plot is identical to the vertical version, but with the x and y axes swapped.
"""
plt.barh(BARPLOT_SAMPLE_IDS, BARPLOT_NUM_READS, color=apc.aster)
apc.mpl.style_axis(ax, monospaced_axes="x")
apc.mpl.style_plot(ax, monospaced_axes="x")
apc.mpl.set_yaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_xaxis())
plt.xticks(rotation=30, ha="right")
Expand Down Expand Up @@ -110,7 +110,7 @@ def plot_vertical_barplot_with_matplotlib_with_categories(ax):
BARPLOT_NUM_READS,
color=colors,
)
apc.mpl.style_axis(ax, monospaced_axes="y")
apc.mpl.style_plot(ax, monospaced_axes="y")
apc.mpl.set_xaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_yaxis())
plt.ylabel("Number of reads")
Expand All @@ -129,7 +129,7 @@ def plot_vertical_barplot_with_seaborn(ax):
saturation=1,
ax=ax,
)
apc.mpl.style_axis(ax, monospaced_axes="y")
apc.mpl.style_plot(ax, monospaced_axes="y")
apc.mpl.set_xaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_yaxis())
plt.ylabel("Number of reads")
Expand All @@ -142,7 +142,7 @@ def plot_horizontal_barplot_with_seaborn(ax):
This plot is identical to the vertical version, but with the x and y axes swapped.
"""
sns.barplot(x=BARPLOT_NUM_READS, y=BARPLOT_SAMPLE_IDS, color=apc.aster, saturation=1, ax=ax)
apc.mpl.style_axis(ax, monospaced_axes="x")
apc.mpl.style_plot(ax, monospaced_axes="x")
apc.mpl.set_yaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_xaxis())
plt.xticks(rotation=30, ha="right")
Expand Down Expand Up @@ -170,7 +170,7 @@ def plot_vertical_barplot_with_seaborn_with_categories(ax):
ax=ax,
)

apc.mpl.style_axis(ax, monospaced_axes="y")
apc.mpl.style_plot(ax, monospaced_axes="y")
apc.mpl.set_xaxis_categorical()
apc.mpl.add_commas_to_axis_tick_labels(ax.get_yaxis())

Expand Down
8 changes: 4 additions & 4 deletions arcadia_pycolor/tests/plotting/test_bespoke_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_plot_stacked_barplot(output_dirpath, figure_size):
assert legend is not None
legend.set_title("Viability")

apc.mpl.style_axis(ax, categorical_axes="x", monospaced_axes="y")
apc.mpl.style_plot(ax, categorical_axes="x", monospaced_axes="y")
apc.mpl.save_figure(fname=(output_dirpath / f"test_plot_stacked_barplot_{figure_size}.pdf"))
plt.close(fig)

Expand All @@ -58,14 +58,14 @@ def test_plot_multiple_line_plot(output_dirpath, figure_size):
figsize=apc.mpl.get_figure_dimensions(figure_size),
)

colors = [apc.aegean, apc.lightgrey, apc.dragon]
colors = [apc.aegean, apc.gray, apc.dragon]
cmap = apc.Gradient(name="", colors=colors).to_mpl_cmap()

for ind, line in enumerate(lines):
ax = axes[ind]
color = cmap(ind / len(lines))
ax.plot(line, color=color)
apc.mpl.style_axis(axis=ax, monospaced_axes="both")
apc.mpl.style_plot(axis=ax, monospaced_axes="both")
ax.set_yticks([])

if ind != len(lines) - 1:
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_plot_heatmaps_with_seaborn(output_dirpath, figure_size):
)

for ax in axs:
apc.mpl.style_axis(
apc.mpl.style_plot(
ax,
categorical_axes="both",
monospaced_axes="both",
Expand Down
4 changes: 2 additions & 2 deletions arcadia_pycolor/tests/plotting/test_seaborn_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def plot_seaborn_scatterplot(ax):
ax=ax,
s=80,
)
apc.mpl.style_axis(monospaced_axes="both")
apc.mpl.style_plot(monospaced_axes="both")


def plot_seaborn_violinplot(ax):
Expand All @@ -56,7 +56,7 @@ def plot_seaborn_violinplot(ax):
palette=colors,
ax=ax,
)
apc.mpl.style_axis(categorical_axes="x", monospaced_axes="y")
apc.mpl.style_plot(categorical_axes="x", monospaced_axes="y")


@pytest.mark.parametrize("figure_size", apc.style_defaults.FIGURE_SIZES.keys())
Expand Down
768 changes: 384 additions & 384 deletions docs/examples/barplot.ipynb

Large diffs are not rendered by default.

212 changes: 106 additions & 106 deletions docs/examples/heatmap.ipynb

Large diffs are not rendered by default.

220 changes: 110 additions & 110 deletions docs/examples/stacked_barplot.ipynb

Large diffs are not rendered by default.

238 changes: 119 additions & 119 deletions docs/examples/stacked_lineplot.ipynb

Large diffs are not rendered by default.

117 changes: 62 additions & 55 deletions docs/style_usage.ipynb

Large diffs are not rendered by default.

0 comments on commit b8564b5

Please sign in to comment.