Draw Y-axis histograms (hbar option not satisfying)

I’m not sure if this is what you want:

bar same

All plotting options can always be found in THistPainter

No it is not doing what I want. I don’t want ot have hbar style in the x axis.
What I want is to keep the style of plot1 and the histograms to be horizontal and not vertical.
So in summary plot1 with a flip of X-Y axis.

The line style has nothing to do with the bar or bar option. In your first plot you every likely have somewhere (in your macro) something like h->SetLineStyle(…).

Yes you are right. I have asked explicitely the style with SetLineStye(2).
What I have seen is that bar or hbar option are making hisotgrams filled by default and destroys the dash-line/not-filled style of my histogram.

My initial question is : how can I have my plot1 with horizontal histograms with this exact same style?

Ah yes… you are right the HBAR is always drawn as filled area never as lines. So you cannot make dashed line with hbar option.

any idea how to simply switch x and y axis ?

If you want a plot like the bar one you showed tI do not see any other way. May be you can try to show it without dotted line. using transparency for instance ?
TGraph would allow to switch axis more easily than TH1. You can try to put your dotted line in a TGraph.

Can you explain me how to do the TGraph with x-y axis switched please?
Or give link to examples?

Instead of doing:


you do


OK it is very simple :slight_smile:

The possibility to change the line style with options Bar and HBAR is now implemented.

   TCanvas *c1 = new TCanvas("c1", "c1",10,45,700,502);

   TH1F *hpx = new TH1F("hpx","This is the px distribution",10,-4,4);



   c1->cd(1); hpx->Draw("HBAR");
   c1->cd(2); hpx->Draw("BAR");

many thanks. I just got a try and I am not able to have what you are showing.
Do I have to use a specific ROOT version?

Oh, it is in the root master … the latest head version of root. i just did the commit.

Last question how to setup the latest head version of ROOT from lxplus?

I guess you will need to install ROOT yourself… As explained here https://github.com/root-project/root

(scroll down the page).

Thanks. I ll have a try.

It works. Many thanks.
Do you know when the new ROOT tag containing this update will be available? And which tag number will it be?

It is now in master only. So it will be in the next release. 6.18. we just release 6.16.

OK thanks a lot for your help.
Topic closed.

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