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
====== 凡例(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() ; * 位置は、図全体の左下を(0,0)、右上を(1,1)として、TLegend(左下X , 左下Y , 右上X , 右上Y)で表す * " f " = box, " l " = " L " = line, " p " = markerを表す *" f " : SetFillColor , SetFillStyle で指定したものを表示 *" l " : SetLineColor で指定したものを表示 *" p " : SetMarkerStyle, SetMarkerColor で指定したものを表示 *TLegendの背景は、デフォルトで灰色 <- 今はもう白になっているよう *なので、SetFillStyle(0)(背景なし)、もしくはSetFillColor(0)(背景白)してやるのがオススメ * 簡単にLegendを出すには、 %%gPad->BuildLegend()%%してやればよい ヒストグラムなどに紐付けされていない、ただの文字を入れるには、入れたいところで legend->AddEntry((TObject*)0,"hoge",""); のようにすれば良い。 凡例のところが空白になって、そのあとに文字が出力されるので、文字を左に詰めたければ legend->AddEntry((TObject*)0,"#kern[-0.3]{hoge}","");// kernはカーニング(文字間隔)のこと。 c.f. TLatex のようにしてやればよい。