|
89 | 89 | #include "TAnnotation.h" |
90 | 90 | #include "TRatioPlot.h" |
91 | 91 | #include "TGaxis.h" |
| 92 | +#include "TPaletteAxis.h" |
92 | 93 | #include "TSpline.h" |
93 | 94 | #include "TPolyMarker.h" |
94 | 95 | #include "TScatter.h" |
@@ -2082,6 +2083,54 @@ void th2_custom_axis_labels() |
2082 | 2083 | } |
2083 | 2084 |
|
2084 | 2085 |
|
| 2086 | +//////////////////////////////////////////////////////////////////////////////// |
| 2087 | +/// Test editing of stats and palette attributes |
| 2088 | + |
| 2089 | +void th2_stats_palette_edit() |
| 2090 | +{ |
| 2091 | + auto C = StartTest(600, 600); |
| 2092 | + |
| 2093 | + gStyle->SetOptStat(); |
| 2094 | + |
| 2095 | + auto hist = new TH2F("th2_stats_palette", "Modify histogram stats and palette", 40, -4, 4, 40, -20, 20); |
| 2096 | + TRandom3 rnr; |
| 2097 | + |
| 2098 | + float px, py; |
| 2099 | + for (int i = 0; i < 25000; i++) { |
| 2100 | + rnr.Rannor(px,py); |
| 2101 | + hist->Fill(px,5*py); |
| 2102 | + } |
| 2103 | + |
| 2104 | + C->SetRightMargin(0.18); |
| 2105 | + auto palette = new TPaletteAxis(4.3, -18, 4.8, 10, hist); |
| 2106 | + hist->GetListOfFunctions()->Add(palette); |
| 2107 | + |
| 2108 | + C->Add(hist, "colz"); |
| 2109 | + |
| 2110 | + C->Update(); |
| 2111 | + |
| 2112 | + TPaveStats *ps = (TPaveStats*)C->GetPrimitive("stats"); |
| 2113 | + ps->SetName("mystats"); |
| 2114 | + TList *listOfLines = ps->GetListOfLines(); |
| 2115 | + |
| 2116 | + // Remove the RMS line |
| 2117 | + while (auto tconst = ps->GetLineWith("Dev")) |
| 2118 | + listOfLines->Remove(tconst); |
| 2119 | + |
| 2120 | + // Add a new line in the stat box. |
| 2121 | + // Note that "=" is a control character |
| 2122 | + TLatex *myt = new TLatex(0,0, "Test = 10"); |
| 2123 | + myt ->SetTextFont(42); |
| 2124 | + myt ->SetTextSize(0.04); |
| 2125 | + myt ->SetTextColor(kRed); |
| 2126 | + listOfLines->Add(myt); |
| 2127 | + |
| 2128 | + // the following line is needed to avoid that the automatic redrawing of stats |
| 2129 | + hist->SetStats(0); |
| 2130 | + |
| 2131 | + TestReport(C, "TH2 with modified palette and stats", "", 0, "th2_stats_palette_edit"); |
| 2132 | +} |
| 2133 | + |
2085 | 2134 | //////////////////////////////////////////////////////////////////////////////// |
2086 | 2135 | /// TEllipse test. |
2087 | 2136 |
|
@@ -4360,6 +4409,7 @@ void stressGraphics(Int_t verbose = 0, Bool_t generate = kFALSE, Bool_t keep_fil |
4360 | 4409 | th2_candle (); |
4361 | 4410 | th2_violin (); |
4362 | 4411 | th2_custom_axis_labels(); |
| 4412 | + th2_stats_palette_edit(); |
4363 | 4413 | tellipse (); |
4364 | 4414 | feynman (); |
4365 | 4415 | ratioplot (); |
|
0 commit comments