Skip to content

Commit

Permalink
fix: comparison histogram (#1228)
Browse files Browse the repository at this point in the history
* fix: change compare histogram to overlapping bars

* fix: remove unused parameter
  • Loading branch information
alexbarros authored and aquemy committed Jan 2, 2023
1 parent 3844ddd commit 09ccae6
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/pandas_profiling/visualisation/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def _plot_histogram(
figsize: tuple = (6, 4),
date: bool = False,
hide_yaxis: bool = False,
vertically: bool = True,
) -> plt.Figure:
"""Plot a histogram from the data and return the AxesSubplot object.
Expand All @@ -41,32 +40,24 @@ def _plot_histogram(
bins: number of bins (int for equal size, ndarray for variable size)
figsize: The size of the figure (width, height) in inches, default (6,4)
date: is the x-axis of date type
vertically: display the histograms vertically if true, and horizontally otherwhise
Returns:
The histogram plot.
"""
# we have precomputed the histograms...
if isinstance(bins, list):
n_labels = len(config.html.style._labels)
if vertically:
fig, ax = plt.subplots(
nrows=n_labels, ncols=1, sharex=True, sharey=True, figsize=figsize
)
else:
fig, ax = plt.subplots(
nrows=1, ncols=n_labels, sharex=True, sharey=True, figsize=figsize
)

for idx in range(n_labels):
plot = ax[idx]
fig = plt.figure(figsize=figsize)
plot = fig.add_subplot(111)

for idx in reversed(list(range(n_labels))):
diff = np.diff(bins[idx])
plot.bar(
bins[idx][:-1] + diff / 2, # type: ignore
series[idx],
diff,
facecolor=config.html.style.primary_colors[idx],
alpha=0.6,
)

if date:
Expand Down Expand Up @@ -127,9 +118,7 @@ def histogram(
The resulting histogram encoded as a string.
"""
plot = _plot_histogram(
config, series, bins, date=date, figsize=(7, 3), vertically=False
)
plot = _plot_histogram(config, series, bins, date=date, figsize=(7, 3))
plot.xaxis.set_tick_params(rotation=90 if date else 45)
plot.figure.tight_layout()
return plot_360_n0sc0pe(config)
Expand Down

0 comments on commit 09ccae6

Please sign in to comment.