Difference: JacobBlancoTutorials (2 vs. 3)

Revision 330 May 2011 - JacoboBlanco

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

Jacob's collection of useful tutorials and tips

Line: 149 to 149
 This should copy all files needed to the ROOTSYS folder you specified in your bash configuration. This should let you run ROOT in the normal way.

Enjoy smile

Added:
>
>

Making beautiful 2D plots

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.*

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.

So normally to plot foo 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:
root [0] gStyle->SetPalette(1)
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.

To make the gradient even smoother you can also add something like the following:

void set_plot_style()
{
    const Int_t NRGBs = 5;
    const Int_t NCont = 255;

    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.

Enjoy!

* http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/

 \ No newline at end of file
 
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