Skip to content

[feat] Could orientation="vertical" be added? #186

@LovelyBuggies

Description

@LovelyBuggies

Hello,

We are designing a lib based on boost-histogram and mplhep. We want to build a plotting function that can draw the 2d histogram and its projections with respect to different axes - plot2d_full in scikit-hep/hist#80.

Everything goes well except this:

import boost_histogram as bh
import mplhep
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms


h = bh.Histogram(bh.axis.Regular(50, -5, 5),
                 bh.axis.Regular(50, -5, 5))

h.fill(
    np.random.normal(size=50_000), np.random.normal(size=50_000)
)

fig = plt.figure(figsize=(5, 5))
grid = fig.add_gridspec(5, 5, hspace=0, wspace=0)

ax1 = fig.add_subplot(grid[1:5, 0:4])
ax2 = fig.add_subplot(grid[0:1, 0:4], sharex=ax1)
ax3 = fig.add_subplot(grid[1:5, 4:5], sharey=ax1)

ax1 = mplhep.hist2dplot(h, ax=ax1, cbar=False)
ax2 = mplhep.histplot(
            h.project(1),
            ax=ax2,
            lw=4
        )


base = plt.gca().transData
rot = transforms.Affine2D().rotate_deg(270)
ax3 = mplhep.histplot(
    h.project(0),
    ax=ax3,
    transform=rot + base,
    lw=4,
)

We expect an output like this:

image

But actually it comes to this:

image

And I find the rotation is not properly displayed:

mplhep.histplot(
    h.project(0),
    transform=rot + base,
    lw=4
)

image

Could you help to find if there is any problem with histplot or where I do mistakenly?

By the way, @henryiii thought using Line2d and QuadMesh, etc. would be a better idea for the return types of histplot/2d, do you think so?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions