Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:root:tlegend

凡例(TLegend)


  TLegend *legend = new TLegend( 0.8, 0.68, 0.99, 0.78) ; //()の中は位置の指定(左下の x , y 、右上の x , y )
  legend->AddEntry( h0, "histogram 0" , "l") ; // AddEntry( pointer , "interpretation" , "option" )
  legend->AddEntry( h1, "histogram 1" , "l") ; // option は "f"=box, "l"="L"=line, "p"=marker
  legend->AddEntry( h2, "histogram 2" , "l") ;
  legend->SetFillColor(0);
  legend->Draw() ;

ヒストグラムなどに紐付けされていない、ただの文字を入れるには、入れたいところで

  legend->AddEntry((TObject*)0,"hoge","");

のようにすれば良い。 凡例のところが空白になって、そのあとに文字が出力されるので、文字を左に詰めたければ

  legend->AddEntry((TObject*)0,"#kern[-0.3]{hoge}","");// kernはカーニング(文字間隔)のこと。 c.f. TLatex

のようにしてやればよい。