myhist->SetLineWidth(3)

Hello,
To give different colors to the several distributions in one canvass I used :slight_smile:
myhist->SetLineWidth(3);
and the header files I have are

#include
#include <TH1F.h>
#include <TCanvas.h>
#include <TFile.h>
#include “TStyle.h”
#include “TLegend.h”
#include “TLatex.h”
#include “TLine.h”
#include “TGraph.h”
#include “TGraphErrors.h”
#include “TPave.h”
#include “TPaveText.h”
#include “TROOT.h”
#include “TString.h”
Whey then colors are not changing?

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


myhist->SetLineWidth(3);

changes the histogram line width, not the file color. To change the color do:

myhist->SetLineColor(kRed);
1 Like

Yes I got it . Thanks.
By using SetLineColor only color of Legend line is changes not the distributions color. What should I do for that?Screenshot%20from%202018-08-24%2011-09-21

myhist->SetFillColor(kRed);

1 Like

Colors of distributions are not changing maybe I need specific header file? In the message above colors are changing but for legends only.

root [0] auto h = new TH1F("h","h",100,-4,4)
root [1] h->SetFillColor(kRed)
root [2] h->FillRandom("gaus");
root [3] h->Draw()

1 Like

This error I got:

can you show me your code ?

Screenshot%20from%202018-08-24%2011-35-41

Now I am not getting that error anymore because “-” was used two times but now still colors are not changing.

Well, kBlack works for me. Can you post here a small macro reproducing your problem ?

1 Like

Please post the reproducer here. Note that what you send me privately does not work. I do not have the root files the macro is using.

1 Like

I solved my that problem about colors.

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