Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/_static/panda-to-star-eased.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/panda-to-star.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ within your current working directory:

Morphing the panda :class:`.Dataset` into the star :class:`.Shape` with marginal plots.

If you don't want the marginal plots (the histograms on the sides), you can use classic mode:
If you don't want the marginal plots (the probability density histograms on the sides),
you can use classic mode:

.. code:: console

Expand Down
49 changes: 19 additions & 30 deletions src/data_morph/plotting/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import EngFormatter, MaxNLocator
from matplotlib.ticker import EngFormatter

from ..data.stats import get_summary_statistics
from .style import plot_with_custom_style
Expand Down Expand Up @@ -89,35 +89,24 @@ def plot(
ax_histx = ax.inset_axes([0, 1.05, 1, 0.25], sharex=ax)
ax_histy = ax.inset_axes([1.05, 0, 0.25, 1], sharey=ax)

ax_histy.xaxis.set_major_formatter(tick_formatter)
ax_histx.yaxis.set_major_formatter(tick_formatter)

(x_marginal_counts, x_marginal_bins), (y_marginal_counts, y_marginal_bins) = (
marginals
)

ax_histx.set(xlim=x_bounds, ylim=(0, np.ceil(x_marginal_counts.max() * 2)))
ax_histy.set(xlim=(0, np.ceil(y_marginal_counts.max() * 2)), ylim=y_bounds)

# no labels on marginal axis that shares with scatter plot
ax_histx.tick_params(axis='x', labelbottom=False)
ax_histy.tick_params(axis='y', labelleft=False)

# move marginal axis ticks that are visible to the corner and only show the non-zero label
locator = MaxNLocator(2, integer=True, prune='lower')
ax_histx.tick_params(axis='y', labelleft=False, labelright=True)
ax_histx.yaxis.set_major_locator(locator)
ax_histy.tick_params(axis='x', labelbottom=False, labeltop=True)
ax_histy.xaxis.set_major_locator(locator)

ax_histx.hist(data.x, bins=x_marginal_bins, color='slategray', ec='black')
ax_histy.hist(
data.y,
bins=y_marginal_bins,
orientation='horizontal',
color='slategray',
ec='black',
)
for marginal_ax, values, (_, bins), orientation in zip(
[ax_histx, ax_histy],
[data.x, data.y],
marginals,
['vertical', 'horizontal'],
strict=True,
):
marginal_ax.xaxis.set_visible(False)
marginal_ax.yaxis.set_visible(False)
marginal_ax.hist(
values,
bins=bins,
density=True,
color='black',
alpha=0.7,
ec='#EAEAF2',
orientation=orientation,
)

res = get_summary_statistics(data, with_median=with_median)

Expand Down
Loading