Can't change ranges on Histogram

_ROOT Version: 6.19
_Platform: OS 10.14.3

I have this code where I modify how a histogram looks and for some reason everything works fine except changing the range of the X axis.

I don’t get any error messages, the axis simply doesn’t change.

The worst part is that the code was working fine yesterday (yes, this is one of those cases).

So I’m pretty confused.

This is my code (2.3 KB)

And this is the JSON file where it reads the style parameters;

		"SetTitle": "nm"
		"SetRangeUser": false,
		"SetTitle": "Arbitrary Units"
		"ngroup": 7,
		"newname": false,
		"xbins": false
		"fname": "gaus",
		"option": false,
		"goption": false,
		"xxmin": false,
		"xxmax": false
	"SetTitle": "Spectrum of the sample",
	"Draw": false

Seems that you do hist.Rebin and plot hist. But Rebin returns a new histogram; try something like line 41 of this tutorial:

   TH1F *hnew2 = (TH1F*)hnew->Rebin(kk,"hnew2",xbins2);

and then, on hnew2, do SetRangeUser, plot, etc.


It works!, thanks!, all I had to do was do the SetRangeUser after the rebining

Great. That was an idea I had too but I wasn’t sure, glad that it works! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.