Commit a2f7da95 authored by connor.hainje@pnnl.gov's avatar connor.hainje@pnnl.gov
Browse files

Continued plot refactor

parent 55f4079d
......@@ -4,11 +4,11 @@ import matplotlib.pyplot as plt
from . import const, colors
from . import distributions as dist
from .utils import (
_ax_xlabel,
connected_region_borders,
imshow_2D_axis_labels,
outer_legend,
better_xlabel,
set_bin_by_xlabel,
text_array_values,
xticks_radians_to_degrees,
)
......@@ -119,7 +119,7 @@ def plot_avg_contribution_1D(df, bin_by="p", title=None, figsize=None, color_lis
fig, ax = plt.subplots(figsize=figsize)
subplot_avg_contribution_1D(ax, df, bin_by=bin_by, color_list=color_list)
fig.tight_layout()
_ax_xlabel(ax, bin_by)
set_bin_by_xlabel(ax, bin_by)
if bin_by == "theta":
xticks_radians_to_degrees(ax)
ax.set_ylabel("Average contribution value")
......
......@@ -2,8 +2,8 @@ import numpy as np
import matplotlib.pyplot as plt
from . import const, colors
from .utils import (
_ax_xlabel,
better_xlabel,
set_bin_by_xlabel,
connected_region_borders,
imshow_2D_axis_labels,
outer_legend,
......@@ -137,7 +137,7 @@ def _plot_1D(subplot_fn, df, bin_by="p", figsize=None, ylabel=None, title=None):
fig, ax = plt.subplots(figsize=figsize)
subplot_fn(ax, df, bin_by=bin_by)
fig.tight_layout()
_ax_xlabel(ax, bin_by)
set_bin_by_xlabel(ax, bin_by)
if bin_by == "theta":
xticks_radians_to_degrees(ax)
ax.set_ylabel(ylabel)
......
This diff is collapsed.
......@@ -187,7 +187,7 @@ def _validate_bin_by_1D(bin_by):
)
def _xlabel_bin_by(bin_by):
def bin_by_label(bin_by):
_validate_bin_by_1D(bin_by)
if bin_by == "p":
return f"$p$ [{const.P_BIN_UNIT}]"
......@@ -195,14 +195,15 @@ def _xlabel_bin_by(bin_by):
return f"$\\theta$ [{const.THETA_BIN_UNIT}]"
def _ax_xlabel(ax, bin_by):
_validate_bin_by_1D(bin_by)
ax.set_xlabel(_xlabel_bin_by(bin_by))
def set_bin_by_xlabel(obj, bin_by):
from matplotlib.figure import Figure
from matplotlib.axes import Axes
def _fig_xlabel(fig, bin_by):
_validate_bin_by_1D(bin_by)
better_xlabel(fig, _xlabel_bin_by(bin_by), fontsize=14)
label = bin_by_label(bin_by)
if isinstance(obj, Figure):
better_xlabel(obj, label)
elif isinstance(obj, Axes):
obj.set_xlabel(label)
def imshow_2D_axis_labels(ax):
......
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