Re: [ROOT] Title and Stat Font Size

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 06 2003 - 22:33:17 MEST


Hi Rainer,

I have made some minor changes in THistPainter::PaintStat and a few 
other functions to optimize alignment & font size
in examples like yours.
The code is now in CVS.

With the new version, setting the font size (relative
to the pad height as usual) will give the same size
in the histogram title and stats box.

Rene Brun

On Fri, 6 Jun 2003 
wanke@uni-mainz.de wrote:

> Dear Rene,
> 
> thanks for the quick answer, and I have probably not been very precise in
> my explanation. Below I send you a small routine which I run in CINT
> without letting any rootlogon or other script run before.
> 
>   > root [0] .L test.C
>   > root [1] test()
> 
> The problem now is the following:
> As you can see, the histogram title and the stats are pretty tiny,
> but I am not able to enlarge them.
> Indeed, the arguments given to
> 
>   MyStyle->SetTitleFontSize(...);
> 
> and
> 
>   MyStyle->SetStatFontSize(...);
> 
> seem to have no effect at all, even when I change them in wide ranges.
> (The label font sizes I am able to set with
> MyStyle->SetLabelSize(...,"XY"), however.)
> 
> This is happening with the ROOT version 3.04/02.
> 
> Cheers,     Rainer
> 
> 
> //
> //  ------------ Test routine starts here ------------------
> //
> #include "TROOT.h"
> #include "TCanvas.h"
> #include "TStyle.h"
> #include "TH1.h"
> 
> void test()
> {
>   // define and set style
>   TStyle *MyStyle = new TStyle("MyStyle","My Style");
>   MyStyle->SetCanvasBorderMode(0);
>   MyStyle->SetCanvasColor(10);
>   MyStyle->SetPadBorderMode(0);
>   MyStyle->SetPadColor(10);
>   MyStyle->SetPadBottomMargin(0.15);
>   MyStyle->SetPadLeftMargin(0.15);
>   MyStyle->SetPaperSize(18,24);
>   MyStyle->SetLabelSize(0.06,"XY");
>   MyStyle->SetLabelOffset(0.01,"Y");
>   MyStyle->SetTitleOffset(1.1,"XY");
>   MyStyle->SetTitleSize(0.06,"XY");
>   MyStyle->SetStatFont(42);
>   MyStyle->SetStatBorderSize(1);
>   MyStyle->SetStatColor(10);
>   MyStyle->SetStatFontSize(0.08);
>   MyStyle->SetTitleBorderSize(1);
>   MyStyle->SetTitleFont(62);
>   MyStyle->SetTitleFontSize(0.08);
> 
>   MyStyle->SetTitleColor(10);
>   MyStyle->SetOptStat(10);
>   gROOT->SetStyle("MyStyle");
> 
>   // open canvas with 6 pads
>   TCanvas *C = new TCanvas( "C", "MyCanvas C", 0, 0, 540, 630 );
>   C->Divide( 2, 3 );
> 
>   // create some dummy histograms
>   TH1D *H1 = new TH1D( "H1", "test title", 100, 0., 10. );
>   TH1D *H2 = new TH1D( "H1", "longer test title", 100, 0., 10. );
>   TH1D *H3 = new TH1D( "H1", "even longer test title", 100, 0., 10. );
> 
>   // now plot them
>   C->cd(1);
>   H1->DrawCopy();
>   C->cd(2);
>   H2->DrawCopy();
>   C->cd(3);
>   H3->DrawCopy();
> 
>   return;
> }
> 
> 
> 
> 
> On Fri, 6 Jun 2003, Rene Brun wrote:
> 
> > Hi rainer,
> >
> > I do not understand your mail. The title and stats box grow/shrink
> > proportionally with ethe pad size, like the axis labels.
> > What do you mean by "histogram size"? I assume you mean "the pad size"
> >
> > Which version of ROOT are you using?
> >
> > Please provide a simple script showing the problem.
> >
> > Rene Brun
> >
> > On
> > Fri,
> > 6 Jun 2003 wanke@uni-mainz.de wrote:
> >
> > > Dear ROOTers,
> > >
> > > I'd like to have the font sizes of the histogram titles and
> > > statistics to be set to a fixed size, which scales with the histogram
> > > size, as this can be done e.g. for the axis labels and titles by
> > > SetLabelSize(0.06) or SetTitleSize(0.06), respectively.
> > >
> > > I tried to use TStyle::SetTitleFontSize() and TStyle::SetStatFontSize(),
> > > but it seems to have no effect, the font size is still adjusted to the
> > > surrounding box rather than the box adjusts to the length of the text.
> > >
> > > I could of course use TStyle::SetTitleH, W, etc. (which works), but then
> > > the font sizes vary from histogram to histogram, depending on the actual
> > > length of the text, making the looks of several histograms on one page
> > > really ugly.
> > > I guess there's a simple way to overcome this?
> > >
> > > Cheers,
> > >                Rainer
> > >
> > > -------------------------------------------------------------------------
> > >    Rainer Wanke
> > >    Institut fuer Physik
> > >    Johannes Gutenberg-Universitaet    Phone:+49+6131/39-25981
> > >    Staudinger Weg 7                   Fax:  +49+6131/39-25169
> > >    D-55099 Mainz
> > > -------------------------------------------------------------------------
> > >
> > >
> >
> >
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET