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

Functionality like root, SetLogz #192

Closed
yszhang95 opened this issue Sep 21, 2020 · 1 comment
Closed

Functionality like root, SetLogz #192

yszhang95 opened this issue Sep 21, 2020 · 1 comment

Comments

@yszhang95
Copy link

Dear experts

I am a newbie of python. Forgive me if I make a stupid question.

I tried to play with 2d histograms with mplhep. I am trying to plot it like ROOT code

TH2D::Draw("COLZ");
TCanvas::SetLogz();

Do we have such functionality in this package or we have to rely on other packages?

Could you please give an example regarding this need?

I found we can use matplotlib.pyplot.yscal('log') to modify x and y axes. But I cannot find any stuff for z axis.

Many thanks in advance.

@andrzejnovak
Copy link
Member

Hi @yszhang95 you can pass "norm" argument to histplot2d which gets passed on to the underlying method pcolormesh

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import mplhep as hep

x = np.linspace(0, 5, 10)
y = np.linspace(5, 10, 10)
H = np.random.uniform(0.01, 20, (9,9))

f, ax = plt.subplots()
hep.hist2dplot(H, x, y, norm=matplotlib.colors.LogNorm(vmin=0.1))

image

Generally a lot of matplotlib solutions can be found on stack overflow https://stackoverflow.com/questions/17201172/a-logarithmic-colorbar-in-matplotlib-scatter-plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants