Difference: JacobBlancoTutorials (7 vs. 8)

Revision 811 Aug 2014 - JacobBlanco

Line: 1 to 1
 
META TOPICPARENT name="JacobBlanco"

Jacob's collection of useful tutorials and tips

Line: 140 to 140
  This will run your script, produce plots and even save them to file as you would normally but simply without drawing them to the screen. As far as I can tell your macro will function just as before except for being a lot faster. This is really useful if you don't really need to look at the plots as things are running. Of course if you're debugging things remove the flag to stare the plots right in the eyes.
Changed:
<
<
Additional Tip: I also add the -q flag when running to force ROOT to quit once the macro has run allowing you to do other stuff in your bash script.
>
>
Additional Tip: I also add the -q flag when running to force ROOT to quit once the macro has run allowing you to do other stuff in your bash script.
 

Making Data vs MC-style plots with SF plot attached

So we've seen these sort of plots everywhere and they are cool (in a PP ROOT plotting sort of way. Stockholm-syndrome much?). They are however a little tricky to get right. Learning the anatomy of a TCanvas is painful and even when you think you know what you're doing, you really don't. You'll have something that looks like that plot below, note that the X-axis of the top plot is behind the bottom plot, so you need to make sure that both top and bottom plot have the same range for things to make sense.

Line: 170 to 170
 Then draw whatever you need on the bottom pad, save the canvas to a root file or output as EPS/PNG/PDF for slides and notes.

Enjoy!

Changed:
<
<

Making beautiful 2D plots

>
>

Update: Making beautiful 2D plots

 
Changed:
<
<
If you've ever made 2D plots in ROOT using the colz command you know how ugly the colours are. If you have no idea what I'm talking about look at the plot on the left, here I'm gonna show you how to turn that into the plot on the right.*
>
>
Edit: After I've written this tutorial I learned a lot about what makes a colour palette effective in conveying information and how the human brain perceives colour. While the mechanism for setting the palette still works well, the palette of colours I used is terrible. Not only do the colours used not convey much information, the palette can also misrepresent the data. Below is the updated tutorial.
 
Changed:
<
<
In this tutorial I will be using a fake 2D histogram called foo. This tutorial will be written in the language of C++ however this can be easily ported to Python if you want to.
>
>
If you've ever made 2D plots in ROOT using the colz command you know how ugly the colours are. In this tutorial I will be using a fake 2D histogram called foo. This tutorial will be written in C++ however this can be easily ported to Python if you want to.
 
Changed:
<
<
So normally to plot foo with a colour gradient one uses the following command
>
>
Normally to plot a TH2 histogram with a colour gradient one uses the following command:
 
root [0] foo->Draw("colz")

This will use the hideous black, pink, bright green and grey palette. To change this behaviour, before running the draw command, run:

Changed:
<
<
root [0] gStyle->SetPalette(1)
>
>
root [0] gStyle->SetPalette(53)
 
Changed:
<
<
This will force the use of the more familiar IR-type gradient for your plots. Remember that if you like this, you can always add this to your global style definition.
>
>
This will force plots to be drawn with a dark body radiator palette that goes from black through red and then white. The intensity of the colour and saturation convey much more information, darker colours represent lower values and brighter colours represent higher values.
  To make the gradient even smoother you can also add something like the following:
Deleted:
<
<
 
void set_plot_style()
{
Changed:
<
<
const Int_t NRGBs = 5;
>
>
gStyle->SetPalette(53);
  const Int_t NCont = 255;
Deleted:
<
<
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
  gStyle->SetNumberContours(NCont); }

This should make your 2D plots much nicer to look at and easier to read.

Changed:
<
<
Enjoy!
>
>
Check out the ColourBrewer tool which was designed to build colour palettes for information maps. You can of course use it to build nice colour palettes for your own 2D plots or 1D distributions when you have lots of related curves. There are a lot of options to play with there, but the most important ones are to select the type of data you're plotting (sequential in the case of 2D plots) and select how many colours you need. Look at the TColour::SetCreateGradientTable function for more information on creating custom palettes.
 
Changed:
<
<
* http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/
>
>
Enjoy!
 
META FILEATTACHMENT attachment="Barrel_smt.png" attr="h" comment="" date="1368263504" name="Barrel_smt.png" path="Barrel_smt.png" size="16795" user="zrap013" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback