Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an orientation parameter in hist #68

Closed
AstroRobin opened this issue Aug 15, 2022 · 4 comments
Closed

Add an orientation parameter in hist #68

AstroRobin opened this issue Aug 15, 2022 · 4 comments
Assignees
Labels
improvement Suggestion for existing code

Comments

@AstroRobin
Copy link
Collaborator

Matplotlib's hist function has an orientation parameter which allows the user to create vertically-oriented histograms, which would be quite useful to try to replicate in splotch.

@AstroRobin AstroRobin added the improvement Suggestion for existing code label Aug 15, 2022
@AstroRobin AstroRobin self-assigned this Aug 15, 2022
@AstroRobin AstroRobin added this to To Do in Modifications to current code via automation Aug 15, 2022
@MBravoS
Copy link
Owner

MBravoS commented Sep 26, 2022

This is something I've thought more than once, but not on a serious manner yet. It's certainly something that we should implement, but I think it's best to explore this and #60 (to use matplotlib.pyplot.step instead of the current kludge) together as one overhaul of plots_1d.hist.

@AstroRobin
Copy link
Collaborator Author

Yep, I agree it's worth revamping plots_1d.hist and it looks like we could make use of some of those additional features. I also think we need to overhaul how we specify parameters (such as colour and linewidths) so that they aren't so specific to the hist_type being used.

@AstroRobin
Copy link
Collaborator Author

Added as of latest push to devel branch. This is perhaps a breaking change for some edge cases but it seems to be working well in my base testing.

arr1 = np.random.normal(0.0,1.0,size=2500)
arr2 = np.random.normal(-1.0,0.5,size=2500)

fig, axes = plt.subplots(figsize=(8,16), ncols=2, nrows=6, squeeze=False)

for jj, orient in enumerate(['horizontal', 'vertical']):
    for ii, htype in enumerate(['line', 'bar', 'step', 'linefilled', 'barfilled', 'stepfilled']):
        hist([arr1, arr2], hist_type=htype, bins=np.linspace(-3, 3, 20), orientation=orient, ax=axes[ii, jj],
             linewidth=[1,2], color=('blue', 'red'), ec=('navy', 'maroon'))
        axes[ii, jj].text(0.9, 0.8, htype, transform=axes[ii, jj].transAxes, ha='right', fontsize=14)

fig.tight_layout()
plt.show()

image

@MBravoS MBravoS moved this from To Do to In Progress in Modifications to current code Nov 2, 2022
@MBravoS
Copy link
Owner

MBravoS commented Nov 4, 2022

It seems to work without issues. I've merged the changes into the master branch.

@MBravoS MBravoS closed this as completed Nov 4, 2022
Modifications to current code automation moved this from In Progress to Done Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Suggestion for existing code
Development

No branches or pull requests

2 participants