SetHistLineWidth

I want to change the line width of my histograms. When I do this

TStyle gStyle;
gStyle.SetHistLineWidth(5);

and then create, fill and draw some histograms, the line width does not change, but instead my 2D histograms suddenly have a quite ugly color palette. How can I (globally) change the line width for my TH1Ds ?

root [0] gROOT->ForceStyle();
root [1] gStyle->SetHistLineWidth(5);
root [2] hpx->Draw()

gives me:


[quote] root [0] gROOT->ForceStyle(); root [1] gStyle->SetHistLineWidth(5); root [2] hpx->Draw() [/quote]

This might work in the console, or in a script (actually I get an error “Symbol hpx is not defined”), but when I want to compile the code, I have no idea how to do it.
I tried this:

include "TH1D.h"
#include "TCanvas.h"
#include "TROOT.h"
#include "TStyle.h"
void test () {
	TROOT* troot = new TROOT();
	troot->ForceStyle();
	TStyle* tstyle = new TStyle();
	tstyle->SetHistLineWidth(6);
	TH1D* h = new TH1D("","",100,0,100);
	for (int i=0;i<100;i++){h->SetBinContent(i+1,i);}
	TCanvas* c = new TCanvas();
	h->Draw();
}

but changing the histLineWidth seems to have no effect.

#include "TROOT.h" #include "TStyle.h" #include "TH1.h" #include "TCanvas.h" void test () { gROOT->ForceStyle(kTRUE); gStyle->SetHistLineWidth(6); TH1D *h = new TH1D("h", "", 100, 0, 100); for (int i = 0; i < 100; i++) { h->SetBinContent(i+1, i); } TCanvas *c = new TCanvas("c"); h->Draw(); c->Modified(); c->Update(); } See also: Changing style of 2-D histogram

Yes that works. Seems like I was just thinking too complicated :confused: