Hi, I am having trouble setting my axes on a TGraph2D. On the forums they mentioned that I could use SetHistogram(), but I don’t know how to use that. All this code is in PyROOT, but the only difference is that pointers are just periods.
c2 = TCanvas( 'c2','Densities',800,800)
gr_dens = TGraph2D()
gr_dens.SetTitle("Energy Density Plot;""x [fm];""y f[m];"" [GeV fm^-3]")
N = 0
for i in range(0,100):
for j in range(0,100):
x_gr_dens = x_grid[i, j]
y_gr_dens = y_grid[i, j]
rho_gr_dens = rho[i,j]*conv
gr_dens.SetPoint(N, x_gr_dens, y_gr_dens, rho_gr_dens)
N +=1
gStyle.SetPalette(55)
gr_dens.Draw("cont4z")
Sorry, yes, I mean axis limits. I would like to set axis limits for the x and y axes on the cont4z plot, but this is difficult. I tried the code below and it did not work.
Sorry it took me a while to respond. I actually ended up using a TH2D instead of a TGraph2D (I had to use that to draw several graphs on the same axis using Draw(“SAME”). I did manage to use h2 -> GetXaxis() -> SetRangeUser for the histogram though. So it was definitely helpful and I got the right axes. Since I’m new, I’ll save this code for future reference, so I can learn more about ROOT. So for now, no more issues. Thanks for your help!