Skip to content

Commit

Permalink
Do not label every bin (#148)
Browse files Browse the repository at this point in the history
* perhaps gratuitous?

* more idiomatic use of major and minor bins
  • Loading branch information
mccalluc authored Nov 7, 2024
1 parent 14f06a1 commit b2e50b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dp_creator_ii/app/components/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ def _df_to_columns(df):


def plot_histogram(histogram_df, error, cutoff): # pragma: no cover
labels, values = _df_to_columns(histogram_df)
bins, values = _df_to_columns(histogram_df)
mod = (len(bins) // 12) + 1
majors = [label for i, label in enumerate(bins) if i % mod == 0]
minors = [label for i, label in enumerate(bins) if i % mod != 0]
_figure, axes = plt.subplots()
bar_colors = ["blue" if v > cutoff else "lightblue" for v in values]
axes.bar(labels, values, color=bar_colors, yerr=error)
axes.bar(bins, values, color=bar_colors, yerr=error)
axes.set_xticks(majors, majors)
axes.set_xticks(minors, ["" for _ in minors], minor=True)
axes.axhline(cutoff, color="lightgrey", zorder=-1)
# TODO: Since this seems to return None, how does the information flow?

0 comments on commit b2e50b4

Please sign in to comment.