38 Double_t *gxwork, *gywork, *gxworkl, *gyworkl;
39 Int_t TGraphPainter::fgMaxPointsPerLine = 50;
41 static Int_t gHighlightPoint = -1;
42 static TGraph *gHighlightGraph = 0;
43 static TMarker *gHighlightMarker = 0;
45 ClassImp(TGraphPainter);
637 TGraphPainter::TGraphPainter()
645 TGraphPainter::~TGraphPainter()
660 void TGraphPainter::ComputeLogs(Int_t npoints, Int_t opt)
665 memcpy(gxworkl,gxwork,npoints*8);
666 memcpy(gyworkl,gywork,npoints*8);
667 if (gPad->GetLogx()) {
668 for (i=0;i<npoints;i++) {
669 if (gxworkl[i] > 0) gxworkl[i] = TMath::Log10(gxworkl[i]);
670 else gxworkl[i] = gPad->GetX1();
673 if (!opt && gPad->GetLogy()) {
674 for (i=0;i<npoints;i++) {
675 if (gyworkl[i] > 0) gyworkl[i] = TMath::Log10(gyworkl[i]);
676 else gyworkl[i] = gPad->GetY1();
688 Int_t TGraphPainter::DistancetoPrimitiveHelper(TGraph *theGraph, Int_t px, Int_t py)
693 if (theGraph->GetHistogram()) {
694 distance = theGraph->GetHistogram()->DistancetoPrimitive(px,py);
695 if (distance <= 5)
return distance;
699 const Int_t big = 9999;
700 const Int_t kMaxDiff = 10;
701 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
702 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
703 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
704 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
707 if (px <= puxmin)
return big;
708 if (py >= puymin)
return big;
709 if (px >= puxmax)
return big;
710 if (py <= puymax)
return big;
713 Int_t i, pxp, pyp, d;
716 Int_t theNpoints = theGraph->GetN();
717 Double_t *theX, *theY;
718 if (theGraph->InheritsFrom(TGraphPolar::Class())) {
719 TGraphPolar *theGraphPolar = (TGraphPolar*) theGraph;
720 theX = theGraphPolar->GetXpol();
721 theY = theGraphPolar->GetYpol();
723 theX = theGraph->GetX();
724 theY = theGraph->GetY();
728 for (i=0;i<theNpoints;i++) {
729 pxp = gPad->XtoAbsPixel(gPad->XtoPad(theX[i]));
730 pyp = gPad->YtoAbsPixel(gPad->YtoPad(theY[i]));
731 d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
738 if (theGraph->IsHighlight())
739 HighlightPoint(theGraph, hpoint, distance);
740 if (distance < kMaxDiff)
return distance;
742 for (i=0;i<theNpoints-1;i++) {
744 d = l.DistancetoLine(px, py, gPad->XtoPad(theX[i]), gPad->YtoPad(theY[i]), gPad->XtoPad(theX[i+1]), gPad->YtoPad(theY[i+1]));
745 if (d < distance) distance = d;
749 TString drawOption = theGraph->GetDrawOption();
750 drawOption.ToLower();
751 if (drawOption.Contains(
"f")) {
752 Double_t xp = gPad->AbsPixeltoX(px); xp = gPad->PadtoX(xp);
753 Double_t yp = gPad->AbsPixeltoY(py); yp = gPad->PadtoY(yp);
754 if (TMath::IsInside(xp,yp,theNpoints,theX,theY) != 0) distance = 1;
759 TList *functions = theGraph->GetListOfFunctions();
760 TIter next(functions);
761 while ((f = (TObject*) next())) {
763 if (f->InheritsFrom(TF1::Class())) dist = f->DistancetoPrimitive(-px,py);
764 else dist = f->DistancetoPrimitive(px,py);
765 if (dist < kMaxDiff) {
766 gPad->SetSelected(f);
778 void TGraphPainter::DrawPanelHelper(TGraph *theGraph)
782 Error(
"DrawPanel",
"need to draw graph first");
785 TVirtualPadEditor *editor = TVirtualPadEditor::GetPadEditor();
787 gROOT->ProcessLine(Form(
"((TCanvas*)0x%lx)->Selected((TVirtualPad*)0x%lx,(TObject*)0x%lx,1)",
788 (ULong_t)gPad->GetCanvas(), (ULong_t)gPad, (ULong_t)theGraph));
803 void TGraphPainter::ExecuteEventHelper(TGraph *theGraph, Int_t event, Int_t px, Int_t py)
809 Double_t xmin, xmax, ymin, ymax, dx, dy, dxr, dyr;
810 const Int_t kMaxDiff = 10;
811 static Bool_t middle, badcase;
812 static Int_t ipoint, pxp, pyp;
813 static Int_t px1,px2,py1,py2;
814 static Int_t pxold, pyold, px1old, py1old, px2old, py2old;
815 static Int_t dpx, dpy;
816 static Int_t *x=0, *y=0;
817 Bool_t opaque = gPad->OpaqueMoving();
819 if (!theGraph->IsEditable() || theGraph->InheritsFrom(TGraphPolar::Class())) {
820 gPad->SetCursor(kHand);
823 if (!gPad->IsEditable())
return;
824 Int_t theNpoints = theGraph->GetN();
825 Double_t *theX = theGraph->GetX();
826 Double_t *theY = theGraph->GetY();
832 gVirtualX->SetLineColor(-1);
833 theGraph->TAttLine::Modify();
834 px1 = gPad->XtoAbsPixel(gPad->GetX1());
835 py1 = gPad->YtoAbsPixel(gPad->GetY1());
836 px2 = gPad->XtoAbsPixel(gPad->GetX2());
837 py2 = gPad->YtoAbsPixel(gPad->GetY2());
842 x =
new Int_t[theNpoints+1];
843 y =
new Int_t[theNpoints+1];
844 for (i=0;i<theNpoints;i++) {
845 pxp = gPad->XtoAbsPixel(gPad->XtoPad(theX[i]));
846 pyp = gPad->YtoAbsPixel(gPad->YtoPad(theY[i]));
847 if (pxp < -kMaxPixel || pxp >= kMaxPixel ||
848 pyp < -kMaxPixel || pyp >= kMaxPixel) {
853 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
854 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
855 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
856 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
860 d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
861 if (d < kMaxDiff) ipoint =i;
867 if (ipoint < 0)
return;
871 px2old = gPad->XtoAbsPixel(theX[1]);
872 py2old = gPad->YtoAbsPixel(theY[1]);
873 }
else if (ipoint == theNpoints-1) {
874 px1old = gPad->XtoAbsPixel(gPad->XtoPad(theX[theNpoints-2]));
875 py1old = gPad->YtoAbsPixel(gPad->YtoPad(theY[theNpoints-2]));
879 px1old = gPad->XtoAbsPixel(gPad->XtoPad(theX[ipoint-1]));
880 py1old = gPad->YtoAbsPixel(gPad->YtoPad(theY[ipoint-1]));
881 px2old = gPad->XtoAbsPixel(gPad->XtoPad(theX[ipoint+1]));
882 py2old = gPad->YtoAbsPixel(gPad->YtoPad(theY[ipoint+1]));
884 pxold = gPad->XtoAbsPixel(gPad->XtoPad(theX[ipoint]));
885 pyold = gPad->YtoAbsPixel(gPad->YtoPad(theY[ipoint]));
893 for (i=0;i<theNpoints;i++) {
894 pxp = gPad->XtoAbsPixel(gPad->XtoPad(theX[i]));
895 pyp = gPad->YtoAbsPixel(gPad->YtoPad(theY[i]));
896 d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
897 if (d < kMaxDiff) middle = kFALSE;
902 if (middle) gPad->SetCursor(kMove);
903 else gPad->SetCursor(kHand);
909 for(i=0;i<theNpoints-1;i++) {
910 gVirtualX->DrawLine(x[i]+dpx, y[i]+dpy, x[i+1]+dpx, y[i+1]+dpy);
913 if (pxp < -kMaxPixel || pxp >= kMaxPixel ||
914 pyp < -kMaxPixel || pyp >= kMaxPixel)
continue;
915 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
916 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
917 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
918 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
920 pxp = x[theNpoints-1]+dpx;
921 pyp = y[theNpoints-1]+dpy;
922 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
923 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
924 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
925 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
930 for(i=0;i<theNpoints-1;i++) {
931 gVirtualX->DrawLine(x[i]+dpx, y[i]+dpy, x[i+1]+dpx, y[i+1]+dpy);
934 if (pxp < -kMaxPixel || pxp >= kMaxPixel ||
935 pyp < -kMaxPixel || pyp >= kMaxPixel)
continue;
936 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
937 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
938 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
939 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
941 pxp = x[theNpoints-1]+dpx;
942 pyp = y[theNpoints-1]+dpy;
943 gVirtualX->DrawLine(pxp-4, pyp-4, pxp+4, pyp-4);
944 gVirtualX->DrawLine(pxp+4, pyp-4, pxp+4, pyp+4);
945 gVirtualX->DrawLine(pxp+4, pyp+4, pxp-4, pyp+4);
946 gVirtualX->DrawLine(pxp-4, pyp+4, pxp-4, pyp-4);
948 if (px1old) gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
949 if (px2old) gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
950 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
951 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
952 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
953 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
955 pxold = TMath::Max(pxold, px1);
956 pxold = TMath::Min(pxold, px2);
958 pyold = TMath::Max(pyold, py2);
959 pyold = TMath::Min(pyold, py1);
960 if (px1old) gVirtualX->DrawLine(px1old, py1old, pxold, pyold);
961 if (px2old) gVirtualX->DrawLine(pxold, pyold, px2old, py2old);
962 gVirtualX->DrawLine(pxold-4, pyold-4, pxold+4, pyold-4);
963 gVirtualX->DrawLine(pxold+4, pyold-4, pxold+4, pyold+4);
964 gVirtualX->DrawLine(pxold+4, pyold+4, pxold-4, pyold+4);
965 gVirtualX->DrawLine(pxold-4, pyold+4, pxold-4, pyold-4);
968 xmin = gPad->GetUxmin();
969 xmax = gPad->GetUxmax();
970 ymin = gPad->GetUymin();
971 ymax = gPad->GetUymax();
974 dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
975 dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
977 if (theGraph->GetHistogram()) {
980 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
981 ymin - dyr*gPad->GetBottomMargin(),
982 xmax + dxr*gPad->GetRightMargin(),
983 ymax + dyr*gPad->GetTopMargin());
984 gPad->RangeAxis(xmin, ymin, xmax, ymax);
991 for(i=0;i<theNpoints;i++) {
992 if (badcase)
continue;
993 if (x) theX[i] = gPad->PadtoX(gPad->AbsPixeltoX(x[i]+dpx));
994 if (y) theY[i] = gPad->PadtoY(gPad->AbsPixeltoY(y[i]+dpy));
998 pxold = TMath::Max(pxold, px1);
999 pxold = TMath::Min(pxold, px2);
1001 pyold = TMath::Max(pyold, py2);
1002 pyold = TMath::Min(pyold, py1);
1003 theX[ipoint] = gPad->PadtoX(gPad->AbsPixeltoX(pxold));
1004 theY[ipoint] = gPad->PadtoY(gPad->AbsPixeltoY(pyold));
1005 if (theGraph->InheritsFrom(
"TCutG")) {
1008 theX[theNpoints-1] = theX[0];
1009 theY[theNpoints-1] = theY[0];
1011 if (ipoint == theNpoints-1) {
1012 theX[0] = theX[theNpoints-1];
1013 theY[0] = theY[theNpoints-1];
1018 gPad->Modified(kTRUE);
1025 if (gROOT->IsEscaped()) {
1026 gROOT->SetEscape(kFALSE);
1033 xmin = gPad->GetUxmin();
1034 xmax = gPad->GetUxmax();
1035 ymin = gPad->GetUymin();
1036 ymax = gPad->GetUymax();
1039 dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
1040 dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
1042 if (theGraph->GetHistogram()) {
1045 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
1046 ymin - dyr*gPad->GetBottomMargin(),
1047 xmax + dxr*gPad->GetRightMargin(),
1048 ymax + dyr*gPad->GetTopMargin());
1049 gPad->RangeAxis(xmin, ymin, xmax, ymax);
1052 for(i=0;i<theNpoints;i++) {
1053 if (badcase)
continue;
1054 if (x) theX[i] = gPad->PadtoX(gPad->AbsPixeltoX(x[i]+dpx));
1055 if (y) theY[i] = gPad->PadtoY(gPad->AbsPixeltoY(y[i]+dpy));
1058 theX[ipoint] = gPad->PadtoX(gPad->AbsPixeltoX(pxold));
1059 theY[ipoint] = gPad->PadtoY(gPad->AbsPixeltoY(pyold));
1060 if (theGraph->InheritsFrom(
"TCutG")) {
1063 theX[theNpoints-1] = theX[0];
1064 theY[theNpoints-1] = theY[0];
1066 if (ipoint == theNpoints-1) {
1067 theX[0] = theX[theNpoints-1];
1068 theY[0] = theY[theNpoints-1];
1075 gPad->Modified(kTRUE);
1076 gVirtualX->SetLineColor(-1);
1083 char *TGraphPainter::GetObjectInfoHelper(TGraph * , Int_t , Int_t )
const
1092 Int_t TGraphPainter::GetHighlightPoint(TGraph *theGraph)
const
1094 if (theGraph == gHighlightGraph)
return gHighlightPoint;
1102 void TGraphPainter::SetHighlight(TGraph *theGraph)
1104 gHighlightPoint = -1;
1105 gHighlightGraph = 0;
1106 if (theGraph->IsHighlight())
return;
1109 if (gHighlightMarker) { gHighlightMarker->Delete(); gHighlightMarker = 0; }
1111 if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, theGraph, gHighlightPoint, -1);
1118 void TGraphPainter::HighlightPoint(TGraph *theGraph, Int_t hpoint, Int_t distance)
1122 const Int_t kHighlightRange = 50;
1123 static Int_t distanceOld = kHighlightRange;
1124 if (gHighlightPoint == -1) distanceOld = kHighlightRange;
1126 if ((distance < kHighlightRange) && (distance < distanceOld)) {
1127 if ((gHighlightPoint != hpoint) || (gHighlightGraph != theGraph)) {
1129 gHighlightPoint = hpoint;
1130 gHighlightGraph = theGraph;
1133 gPad->Modified(kTRUE);
1137 if (gPad->GetCanvas()) gPad->GetCanvas()->Highlighted(gPad, theGraph, gHighlightPoint, -1);
1140 if (gHighlightGraph == theGraph) distanceOld = distance;
1147 void TGraphPainter::PaintHighlightPoint(TGraph *theGraph, Option_t * )
1151 if ((!theGraph->IsHighlight()) || (gHighlightGraph != theGraph))
return;
1154 if (theGraph->GetPoint(gHighlightPoint, hx, hy) == -1) {
1156 if (gHighlightMarker) { gHighlightMarker->Delete(); gHighlightMarker = 0; }
1160 Double_t uxmin = gPad->GetUxmin();
1161 Double_t uxmax = gPad->GetUxmax();
1162 Double_t uymin = gPad->GetUymin();
1163 Double_t uymax = gPad->GetUymax();
1164 if (gPad->GetLogx()) {
1165 uxmin = TMath::Power(10.0, uxmin);
1166 uxmax = TMath::Power(10.0, uxmax);
1168 if (gPad->GetLogy()) {
1169 uymin = TMath::Power(10.0, uymin);
1170 uymax = TMath::Power(10.0, uymax);
1172 if ((hx < uxmin) || (hx > uxmax))
return;
1173 if ((hy < uymin) || (hy > uymax))
return;
1175 if (!gHighlightMarker) {
1176 gHighlightMarker =
new TMarker(hx, hy, 24);
1177 gHighlightMarker->SetBit(kCannotPick);
1179 gHighlightMarker->SetX(hx);
1180 gHighlightMarker->SetY(hy);
1181 gHighlightMarker->SetMarkerSize(theGraph->GetMarkerSize()*2.0);
1182 if (gHighlightMarker->GetMarkerSize() < 1.0) gHighlightMarker->SetMarkerSize(1.0);
1183 gHighlightMarker->SetMarkerColor(theGraph->GetMarkerColor());
1184 gHighlightMarker->Paint();
1193 void TGraphPainter::PaintHelper(TGraph *theGraph, Option_t *option)
1197 strlcpy(chopt,option,80);
1200 char *l1 = strstr(chopt,
"pfc");
1201 char *l2 = strstr(chopt,
"plc");
1202 char *l3 = strstr(chopt,
"pmc");
1203 if (l1 || l2 || l3) {
1204 Int_t i = gPad->NextPaletteColor();
1205 if (l1) {memcpy(l1,
" ",3); theGraph->SetFillColor(i);}
1206 if (l2) {memcpy(l2,
" ",3); theGraph->SetLineColor(i);}
1207 if (l3) {memcpy(l3,
" ",3); theGraph->SetMarkerColor(i);}
1210 SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
1212 char *l4 = strstr(chopt,
"rx");
1213 char *l5 = strstr(chopt,
"ry");
1216 PaintGraphReverse(theGraph,chopt);
1220 if (theGraph->InheritsFrom(TGraphBentErrors::Class())) {
1221 PaintGraphBentErrors(theGraph,chopt);
1222 }
else if (theGraph->InheritsFrom(TGraphQQ::Class())) {
1223 PaintGraphQQ(theGraph,chopt);
1224 }
else if (theGraph->InheritsFrom(TGraphAsymmErrors::Class())) {
1225 PaintGraphAsymmErrors(theGraph,chopt);
1226 }
else if (theGraph->InheritsFrom(TGraphMultiErrors::Class())) {
1227 PaintGraphMultiErrors(theGraph,chopt);
1228 }
else if (theGraph->InheritsFrom(TGraphErrors::Class())) {
1229 if (theGraph->InheritsFrom(TGraphPolar::Class())) {
1230 PaintGraphPolar(theGraph,chopt);
1232 PaintGraphErrors(theGraph,chopt);
1235 PaintGraphSimple(theGraph,chopt);
1240 TList *functions = theGraph->GetListOfFunctions();
1243 f = (TF1*)functions->First();
1245 if (f->InheritsFrom(TF1::Class())) fit = (TF1*)f;
1247 TIter next(functions);
1248 while ((f = (TObject*) next())) {
1249 if (f->InheritsFrom(TF1::Class())) {
1255 if (fit) PaintStats(theGraph, fit);
1264 void TGraphPainter::PaintGraph(TGraph *theGraph, Int_t npoints,
const Double_t *x,
const Double_t *y, Option_t *chopt)
1267 if (theGraph->InheritsFrom(
"TGraphPolar"))
1268 gPad->PushSelectableObject(theGraph);
1270 Int_t optionLine , optionAxis , optionCurve , optionStar , optionMark;
1271 Int_t optionBar , optionR , optionOne , optionE;
1272 Int_t optionFill , optionZ , optionCurveFill, optionIAxis;
1273 Int_t i, npt, nloop;
1275 Double_t xlow, xhigh, ylow, yhigh;
1276 Double_t barxmin, barxmax, barymin, barymax;
1277 Double_t uxmin, uxmax;
1278 Double_t x1, xn, y1, yn;
1279 Double_t dbar, bdelta;
1280 Int_t theNpoints = theGraph->GetN();
1283 Error(
"PaintGraph",
"illegal number of points (%d)", npoints);
1286 TString opt = chopt;
1288 opt.ReplaceAll(
"SAME",
"");
1290 if (opt.Contains(
"L")) optionLine = 1;
else optionLine = 0;
1291 if (opt.Contains(
"A")) optionAxis = 1;
else optionAxis = 0;
1292 if (opt.Contains(
"C")) optionCurve = 1;
else optionCurve = 0;
1293 if (opt.Contains(
"*")) optionStar = 1;
else optionStar = 0;
1294 if (opt.Contains(
"P")) optionMark = 1;
else optionMark = 0;
1295 if (opt.Contains(
"B")) optionBar = 1;
else optionBar = 0;
1296 if (opt.Contains(
"R")) optionR = 1;
else optionR = 0;
1297 if (opt.Contains(
"1")) optionOne = 1;
else optionOne = 0;
1298 if (opt.Contains(
"F")) optionFill = 1;
else optionFill = 0;
1299 if (opt.Contains(
"I")) optionIAxis = 1;
else optionIAxis = 0;
1300 if (opt.Contains(
"2") || opt.Contains(
"3") ||
1301 opt.Contains(
"4") || opt.Contains(
"5")) optionE = 1;
else optionE = 0;
1305 if (optionLine+optionFill+optionCurve+optionStar+optionMark+optionBar+optionE == 0) {
1306 if (!chopt[0]) optionLine=1;
1310 if (optionStar) theGraph->SetMarkerStyle(3);
1312 optionCurveFill = 0;
1313 if (optionCurve && optionFill) {
1314 optionCurveFill = 1;
1319 Double_t rwxmin,rwxmax, rwymin, rwymax, maximum, minimum, dx, dy;
1321 if (theGraph->GetHistogram()) {
1322 rwxmin = gPad->GetUxmin();
1323 rwxmax = gPad->GetUxmax();
1324 rwymin = gPad->GetUymin();
1325 rwymax = gPad->GetUymax();
1326 minimum = theGraph->GetHistogram()->GetMinimumStored();
1327 maximum = theGraph->GetHistogram()->GetMaximumStored();
1328 if (minimum == -1111) {
1329 minimum = theGraph->GetHistogram()->GetYaxis()->GetXmin();
1330 theGraph->GetHistogram()->SetMinimum(minimum);
1332 if (maximum == -1111) {
1333 maximum = theGraph->GetHistogram()->GetYaxis()->GetXmax();
1334 theGraph->GetHistogram()->SetMaximum(maximum);
1336 uxmin = gPad->PadtoX(rwxmin);
1337 uxmax = gPad->PadtoX(rwxmax);
1340 theGraph->ComputeRange(rwxmin, rwymin, rwxmax, rwymax);
1342 if (rwxmin == rwxmax) rwxmax += 1.;
1343 if (rwymin == rwymax) rwymax += 1.;
1344 dx = 0.1*(rwxmax-rwxmin);
1345 dy = 0.1*(rwymax-rwymin);
1346 uxmin = rwxmin - dx;
1347 uxmax = rwxmax + dx;
1348 minimum = rwymin - dy;
1349 maximum = rwymax + dy;
1351 if (theGraph->GetMinimum() != -1111) rwymin = minimum = theGraph->GetMinimum();
1352 if (theGraph->GetMaximum() != -1111) rwymax = maximum = theGraph->GetMaximum();
1353 if (uxmin < 0 && rwxmin >= 0) uxmin = 0.9*rwxmin;
1354 if (uxmax > 0 && rwxmax <= 0) {
1355 if (gPad->GetLogx()) uxmax = 1.1*rwxmax;
1358 if (minimum < 0 && rwymin >= 0) minimum = 0.9*rwymin;
1359 if (maximum > 0 && rwymax <= 0) {
1363 if (minimum <= 0 && gPad->GetLogy()) minimum = 0.001*maximum;
1364 if (uxmin <= 0 && gPad->GetLogx()) {
1365 if (uxmax > 1000) uxmin = 1;
1366 else uxmin = 0.001*uxmax;
1373 char chopth[8] =
" ";
1374 if (strstr(chopt,
"x+")) strncat(chopth,
"x+",3);
1375 if (strstr(chopt,
"y+")) strncat(chopth,
"y+",3);
1376 if (optionIAxis) strncat(chopth,
"A",2);
1377 if (!theGraph->GetHistogram()) {
1383 if (theNpoints > npt) npt = theNpoints;
1384 TH1F *h =
new TH1F(Form(
"%s_h",GetName()),GetTitle(),npt,rwxmin,rwxmax);
1385 theGraph->SetHistogram(h);
1386 if (!theGraph->GetHistogram())
return;
1387 theGraph->GetHistogram()->SetMinimum(rwymin);
1388 theGraph->GetHistogram()->SetMaximum(rwymax);
1389 theGraph->GetHistogram()->GetYaxis()->SetLimits(rwymin,rwymax);
1390 theGraph->GetHistogram()->SetBit(TH1::kNoStats);
1391 theGraph->GetHistogram()->SetDirectory(0);
1392 theGraph->GetHistogram()->Sumw2(kFALSE);
1393 theGraph->GetHistogram()->Paint(chopth);
1395 if (gPad->GetLogy()) {
1396 theGraph->GetHistogram()->SetMinimum(rwymin);
1397 theGraph->GetHistogram()->SetMaximum(rwymax);
1398 theGraph->GetHistogram()->GetYaxis()->SetLimits(rwymin,rwymax);
1400 theGraph->GetHistogram()->Sumw2(kFALSE);
1401 theGraph->GetHistogram()->Paint(chopth);
1406 gPad->SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
1408 rwxmin = gPad->GetUxmin();
1409 rwxmax = gPad->GetUxmax();
1410 rwymin = gPad->GetUymin();
1411 rwymax = gPad->GetUymax();
1412 uxmin = gPad->PadtoX(rwxmin);
1413 uxmax = gPad->PadtoX(rwxmax);
1414 if (theGraph->GetHistogram() && !theGraph->InheritsFrom(
"TGraphPolar")) {
1415 maximum = theGraph->GetHistogram()->GetMaximum();
1416 minimum = theGraph->GetHistogram()->GetMinimum();
1418 maximum = gPad->PadtoY(rwymax);
1419 minimum = gPad->PadtoY(rwymin);
1423 theGraph->TAttLine::Modify();
1424 theGraph->TAttFill::Modify();
1425 theGraph->TAttMarker::Modify();
1428 gxwork =
new Double_t[2*npoints+10];
1429 gywork =
new Double_t[2*npoints+10];
1430 gxworkl =
new Double_t[2*npoints+10];
1431 gyworkl =
new Double_t[2*npoints+10];
1433 if (optionLine || optionFill) {
1439 if (optionFill && (xn != x1 || yn != y1)) nloop++;
1441 for (i=1;i<=nloop;i++) {
1443 gxwork[npt] = gxwork[0]; gywork[npt] = gywork[0];
1445 gxwork[npt] = x[i-1]; gywork[npt] = y[i-1];
1449 ComputeLogs(npt, optionZ);
1450 Int_t bord = gStyle->GetDrawBorder();
1453 gPad->PaintFillArea(npt,gyworkl,gxworkl);
1454 if (bord) gPad->PaintPolyLine(npt,gyworkl,gxworkl);
1457 if (TMath::Abs(theGraph->GetLineWidth())>99) PaintPolyLineHatches(theGraph, npt, gyworkl, gxworkl);
1458 gPad->PaintPolyLine(npt,gyworkl,gxworkl);
1462 gPad->PaintFillArea(npt,gxworkl,gyworkl);
1463 if (bord) gPad->PaintPolyLine(npt,gxworkl,gyworkl);
1466 if (TMath::Abs(theGraph->GetLineWidth())>99) PaintPolyLineHatches(theGraph, npt, gxworkl, gyworkl);
1467 gPad->PaintPolyLine(npt,gxworkl,gyworkl);
1470 gxwork[0] = gxwork[npt-1]; gywork[0] = gywork[npt-1];
1484 if (optionCurveFill) {
1486 if (xn != x1 || yn != y1) nloop++;
1490 for (i=1;i<=nloop;i++) {
1492 gxwork[npt] = gxwork[0]; gywork[npt] = gywork[0];
1494 gxwork[npt] = x[i-1]; gywork[npt] = y[i-1];
1497 ComputeLogs(npt, optionZ);
1498 if (gyworkl[npt-1] < rwymin || gyworkl[npt-1] > rwymax) {
1500 ComputeLogs(npt, optionZ);
1501 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
1503 gxwork[0] = gxwork[npt-1]; gywork[0] = gywork[npt-1];
1509 ComputeLogs(npt, optionZ);
1510 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
1515 for (i=1;i<=nloop;i++) {
1517 gxwork[npt] = gxwork[0]; gywork[npt] = gywork[0];
1519 if (y[i-1] < minimum || y[i-1] > maximum)
continue;
1520 if (x[i-1] < uxmin || x[i-1] > uxmax)
continue;
1521 gxwork[npt] = x[i-1]; gywork[npt] = y[i-1];
1524 ComputeLogs(npt, optionZ);
1525 if (gxworkl[npt-1] < rwxmin || gxworkl[npt-1] > rwxmax) {
1527 ComputeLogs(npt, optionZ);
1528 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
1530 gxwork[0] = gxwork[npt-1]; gywork[0] = gywork[npt-1];
1536 ComputeLogs(npt, optionZ);
1537 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
1544 theGraph->SetMarkerStyle(3);
1546 for (i=1;i<=npoints;i++) {
1547 gxwork[npt] = x[i-1]; gywork[npt] = y[i-1];
1550 ComputeLogs(npt, optionZ);
1551 if (optionR) gPad->PaintPolyMarker(npt,gyworkl,gxworkl);
1552 else gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
1561 for (i=1;i<=npoints;i++) {
1562 gxwork[npt] = x[i-1]; gywork[npt] = y[i-1];
1565 ComputeLogs(npt, optionZ);
1566 if (optionR) gPad->PaintPolyMarker(npt,gyworkl,gxworkl);
1567 else gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
1578 for (i=1;i<npoints;i++) {
1579 if (x[i] < barxmin) barxmin = x[i];
1580 if (x[i] > barxmax) barxmax = x[i];
1582 bdelta = (barxmax-barxmin)/Double_t(npoints);
1586 for (i=1;i<npoints;i++) {
1587 if (y[i] < barymin) barymin = y[i];
1588 if (y[i] > barymax) barymax = y[i];
1590 bdelta = (barymax-barymin)/Double_t(npoints);
1592 dbar = 0.5*bdelta*gStyle->GetBarWidth();
1594 for (i=1;i<=npoints;i++) {
1595 xlow = x[i-1] - dbar;
1596 xhigh = x[i-1] + dbar;
1598 if (xlow < uxmin && xhigh < uxmin)
continue;
1599 if (xhigh > uxmax && xlow > uxmax)
continue;
1600 if (xlow < uxmin) xlow = uxmin;
1601 if (xhigh > uxmax) xhigh = uxmax;
1602 if (!optionOne) ylow = TMath::Max((Double_t)0,gPad->GetUymin());
1603 else ylow = gPad->GetUymin();
1608 ComputeLogs(2, optionZ);
1609 if (gyworkl[0] < gPad->GetUymin()) gyworkl[0] = gPad->GetUymin();
1610 if (gyworkl[1] < gPad->GetUymin())
continue;
1611 if (gyworkl[1] > gPad->GetUymax()) gyworkl[1] = gPad->GetUymax();
1612 if (gyworkl[0] > gPad->GetUymax())
continue;
1614 gPad->PaintBox(gxworkl[0],gyworkl[0],gxworkl[1],gyworkl[1]);
1617 for (i=1;i<=npoints;i++) {
1619 ylow = y[i-1] - dbar;
1620 yhigh = y[i-1] + dbar;
1621 xlow = TMath::Max((Double_t)0, gPad->GetUxmin());
1626 ComputeLogs(2, optionZ);
1627 gPad->PaintBox(gxworkl[0],gyworkl[0],gxworkl[1],gyworkl[1]);
1631 gPad->ResetBit(TGraph::kClipFrame);
1669 void TGraphPainter::PaintGrapHist(TGraph *theGraph, Int_t npoints,
const Double_t *x,
1670 const Double_t *y, Option_t *chopt)
1673 const char *where =
"PaintGrapHist";
1675 Int_t optionLine , optionAxis , optionCurve, optionStar, optionMark;
1676 Int_t optionBar , optionRot , optionOne , optionOff ;
1677 Int_t optionFill , optionZ;
1678 Int_t optionHist , optionBins , optionMarker;
1680 Int_t drawtype=0, drawborder, drawbordersav;
1681 Double_t xlow, xhigh, ylow, yhigh;
1682 Double_t wmin, wmax;
1683 Double_t dbar, offset, wminstep;
1686 Double_t xi, xi1, xj, xj1, yi1, yi, yj, yj1, xwmin, ywmin;
1687 Int_t first, last, nbins;
1690 char choptaxis[10] =
" ";
1693 Error(where,
"illegal number of points (%d)", npoints);
1696 TString opt = chopt;
1698 if (opt.Contains(
"H")) optionHist = 1;
else optionHist = 0;
1699 if (opt.Contains(
"F")) optionFill = 1;
else optionFill = 0;
1700 if (opt.Contains(
"C")) optionCurve= 1;
else optionCurve= 0;
1701 if (opt.Contains(
"*")) optionStar = 1;
else optionStar = 0;
1702 if (opt.Contains(
"R")) optionRot = 1;
else optionRot = 0;
1703 if (opt.Contains(
"1")) optionOne = 1;
else optionOne = 0;
1704 if (opt.Contains(
"B")) optionBar = 1;
else optionBar = 0;
1705 if (opt.Contains(
"N")) optionBins = 1;
else optionBins = 0;
1706 if (opt.Contains(
"L")) optionLine = 1;
else optionLine = 0;
1707 if (opt.Contains(
"P")) optionMark = 1;
else optionMark = 0;
1708 if (opt.Contains(
"A")) optionAxis = 1;
else optionAxis = 0;
1709 if (opt.Contains(
"][")) optionOff = 1;
else optionOff = 0;
1710 if (opt.Contains(
"P0")) optionMark = 10;
1712 Int_t optionFill2 = 0;
1713 if (opt.Contains(
"F") && opt.Contains(
"2")) {
1714 optionFill = 0; optionFill2 = 1;
1719 if (theGraph->TestBit(TGraph::kClipFrame)) noClip =
"";
1721 gPad->SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
1725 if (optionStar) theGraph->SetMarkerStyle(3);
1729 nbins = last - first + 1;
1733 Double_t baroffset = gStyle->GetBarOffset();
1734 Double_t barwidth = gStyle->GetBarWidth();
1735 Double_t rwxmin = gPad->GetUxmin();
1736 Double_t rwxmax = gPad->GetUxmax();
1737 Double_t rwymin = gPad->GetUymin();
1738 Double_t rwymax = gPad->GetUymax();
1739 Double_t uxmin = gPad->PadtoX(rwxmin);
1740 Double_t uxmax = gPad->PadtoX(rwxmax);
1741 Double_t rounding = (uxmax-uxmin)*1.e-5;
1742 drawborder = gStyle->GetDrawBorder();
1744 Int_t nx1, nx2, ndivx, ndivy, ndiv;
1746 Double_t rwmin = rwxmin;
1747 Double_t rwmax = rwxmax;
1748 ndivx = gStyle->GetNdivisions(
"X");
1749 ndivy = gStyle->GetNdivisions(
"Y");
1752 nx1 = TMath::Max(1, ndivx%100);
1753 ndivx = 100*nx2 + Int_t(Double_t(nx1)*gPad->GetAbsWNDC());
1755 ndiv =TMath::Abs(ndivx);
1757 if (ndivx < 0) strlcat(choptaxis,
"N",10);
1758 if (gPad->GetGridx()) {
1760 strlcat(choptaxis,
"W",10);
1762 if (gPad->GetLogx()) {
1763 rwmin = TMath::Power(10,rwxmin);
1764 rwmax = TMath::Power(10,rwxmax);
1766 strlcat(choptaxis,
"G",10);
1768 TGaxis *axis =
new TGaxis();
1769 axis->SetLineColor(gStyle->GetAxisColor(
"X"));
1770 axis->SetTextColor(gStyle->GetLabelColor(
"X"));
1771 axis->SetTextFont(gStyle->GetLabelFont(
"X"));
1772 axis->SetLabelSize(gStyle->GetLabelSize(
"X"));
1773 axis->SetLabelOffset(gStyle->GetLabelOffset(
"X"));
1774 axis->SetTickSize(gStyle->GetTickLength(
"X"));
1776 axis->PaintAxis(rwxmin,rwymin,rwxmax,rwymin,rwmin,rwmax,ndiv,choptaxis);
1783 nx1 = TMath::Max(1, ndivy%100);
1784 ndivy = 100*nx2 + Int_t(Double_t(nx1)*gPad->GetAbsHNDC());
1786 strlcat(choptaxis,
"N",10);
1788 ndiv =TMath::Abs(ndivy);
1789 if (gPad->GetGridy()) {
1791 strlcat(choptaxis,
"W",10);
1793 if (gPad->GetLogy()) {
1794 rwmin = TMath::Power(10,rwymin);
1795 rwmax = TMath::Power(10,rwymax);
1797 strlcat(choptaxis,
"G",10);
1799 axis->SetLineColor(gStyle->GetAxisColor(
"Y"));
1800 axis->SetTextColor(gStyle->GetLabelColor(
"Y"));
1801 axis->SetTextFont(gStyle->GetLabelFont(
"Y"));
1802 axis->SetLabelSize(gStyle->GetLabelSize(
"Y"));
1803 axis->SetLabelOffset(gStyle->GetLabelOffset(
"Y"));
1804 axis->SetTickSize(gStyle->GetTickLength(
"Y"));
1806 axis->PaintAxis(rwxmin,rwymin,rwxmin,rwymax,rwmin,rwmax,ndiv,choptaxis);
1812 theGraph->TAttLine::Modify();
1813 theGraph->TAttFill::Modify();
1814 theGraph->TAttMarker::Modify();
1818 if (!optionRot) {wmin = x[0]; wmax = x[1];}
1819 else {wmin = y[0]; wmax = y[1];}
1821 if (!optionBins) delta = (wmax - wmin)/ Double_t(nbins);
1823 Int_t fwidth = gPad->GetFrameLineWidth();
1824 TFrame *frame = gPad->GetFrame();
1825 if (frame) fwidth = frame->GetLineWidth();
1826 if (optionOff) fwidth = 1;
1827 Double_t dxframe = gPad->AbsPixeltoX(fwidth/2) - gPad->AbsPixeltoX(0);
1828 Double_t vxmin = gPad->PadtoX(gPad->GetUxmin() + dxframe);
1829 Double_t vxmax = gPad->PadtoX(gPad->GetUxmax() - dxframe);
1830 Double_t dyframe = -gPad->AbsPixeltoY(fwidth/2) + gPad->AbsPixeltoY(0);
1831 Double_t vymin = gPad->GetUymin() + dyframe;
1832 vxmin = TMath::Max(vxmin,wmin);
1833 vxmax = TMath::Min(vxmax,wmax);
1837 gxwork =
new Double_t[2*npoints+10];
1838 gywork =
new Double_t[2*npoints+10];
1839 gxworkl =
new Double_t[2*npoints+10];
1840 gyworkl =
new Double_t[2*npoints+10];
1842 if (optionFill && !optionCurve) {
1846 if (!optionOne) gywork[0] = TMath::Min(TMath::Max((Double_t)0,gPad->GetUymin())
1848 else gywork[0] = gPad->GetUymin();
1850 for (j=first; j<=last;j++) {
1852 gxwork[npt-1] = gxwork[npt-2];
1853 gxwork[npt] = wmin+((j-first+1)*delta);
1854 if (gxwork[npt] < gxwork[0]) gxwork[npt] = gxwork[0];
1857 xj1 = x[j]; xj = x[j-1];
1859 if (j != last) Error(where,
"X must be in increasing order");
1860 else Error(where,
"X must have N+1 values with option N");
1863 gxwork[npt-1] = x[j-1]; gxwork[npt] = x[j];
1865 gywork[npt-1] = y[j-1];
1866 gywork[npt] = y[j-1];
1867 if (gywork[npt] < vymin) {gywork[npt] = vymin; gywork[npt-1] = vymin;}
1868 if ((gxwork[npt-1] >= uxmin-rounding && gxwork[npt-1] <= uxmax+rounding) ||
1869 (gxwork[npt] >= uxmin-rounding && gxwork[npt] <= uxmax+rounding)) npt += 2;
1871 gxwork[npt-1] = gxwork[npt-2];
1872 gywork[npt-1] = gywork[0];
1875 if (gxwork[0 ] < vxmin) {gxwork[0 ] = vxmin; gxwork[1 ] = vxmin;}
1876 if (gywork[0] < vymin) {gywork[0] = vymin; gywork[npt-1] = vymin;}
1879 ComputeLogs(npt, optionZ);
1880 gPad->PaintFillArea(npt,gxworkl,gyworkl);
1882 if (!fillarea) gyworkl[0] = ylast;
1883 gPad->PaintPolyLine(npt-1,gxworkl,gyworkl,noClip);
1890 if (!optionOne) gxwork[0] = TMath::Max((Double_t)0,gPad->GetUxmin());
1891 else gxwork[0] = gPad->GetUxmin();
1893 for (j=first; j<=last;j++) {
1895 gywork[npt-1] = gywork[npt-2];
1896 gywork[npt] = wmin+((j-first+1)*delta);
1898 yj1 = y[j]; yj = y[j-1];
1900 if (j != last) Error(where,
"Y must be in increasing order");
1901 else Error(where,
"Y must have N+1 values with option N");
1904 gywork[npt-1] = y[j-1]; gywork[npt] = y[j];
1906 gxwork[npt-1] = x[j-1]; gxwork[npt] = x[j-1];
1907 if ((gxwork[npt-1] >= uxmin-rounding && gxwork[npt-1] <= uxmax+rounding) ||
1908 (gxwork[npt] >= uxmin-rounding && gxwork[npt] <= uxmax+rounding)) npt += 2;
1910 gywork[npt-1] = gywork[npt-2];
1911 gxwork[npt-1] = gxwork[0];
1912 ComputeLogs(npt, optionZ);
1913 gPad->PaintFillArea(npt,gxworkl,gyworkl);
1915 if (!fillarea) gyworkl[0] = ylast;
1916 gPad->PaintPolyLine(npt-1,gxworkl,gyworkl,noClip);
1922 theGraph->TAttLine::Modify();
1923 theGraph->TAttFill::Modify();
1928 if ((optionHist) || !chopt[0]) {
1931 gywork[0] = gPad->GetUymin();
1934 for (i=first; i<=last;i++) {
1936 gxwork[npt-1] = gxwork[npt-2];
1937 gxwork[npt] = wmin+((i-first+1)*delta);
1939 xi1 = x[i]; xi = x[i-1];
1941 if (i != last) Error(where,
"X must be in increasing order");
1942 else Error(where,
"X must have N+1 values with option N");
1945 gxwork[npt-1] = x[i-1]; gxwork[npt] = x[i];
1947 gywork[npt-1] = y[i-1];
1948 gywork[npt] = y[i-1];
1949 if (gywork[npt] < vymin) {gywork[npt] = vymin; gywork[npt-1] = vymin;}
1950 if ((gxwork[npt-1] >= uxmin-rounding && gxwork[npt-1] <= uxmax+rounding) ||
1951 (gxwork[npt] >= uxmin-rounding && gxwork[npt] <= uxmax+rounding)) npt += 2;
1953 gxwork[npt-1] = gxwork[npt-2];
1954 gywork[npt-1] = gywork[0];
1957 if (gxwork[0] < vxmin) {gxwork[0] = vxmin; gxwork[1 ] = vxmin;}
1958 if (gywork[0] < vymin) {gywork[0] = vymin; gywork[npt-1] = vymin;}
1960 ComputeLogs(npt, optionZ);
1963 Int_t nbpoints = npt-2;
1969 for (ip=point1; ip<=nbpoints; ip++) {
1970 if (gyworkl[ip] != ywmin) {
1976 Int_t point2 = nbpoints;
1977 for (ip=point2; ip>=point1; ip--) {
1978 if (gyworkl[ip] != ywmin) {
1983 nbpoints = point2-point1+1;
1987 if (gxwork[0] > gPad->GetUxmin()) { nbpoints++; point1 = 0; }
1988 if (gxwork[nbpoints] < gPad->GetUxmax()) nbpoints++;
1991 gPad->PaintPolyLine(nbpoints,&gxworkl[point1],&gyworkl[point1],noClip);
1997 gxwork[0] = TMath::Max((Double_t)0,gPad->GetUxmin());
2000 for (i=first; i<=last;i++) {
2002 gywork[npt-1] = gywork[npt-2];
2003 gywork[npt] = wmin+((i-first+1)*delta);
2005 yi1 = y[i]; yi = y[i-1];
2007 if (i != last) Error(where,
"Y must be in increasing order");
2008 else Error(where,
"Y must have N+1 values with option N");
2011 gywork[npt-1] = y[i-1]; gywork[npt] = y[i];
2013 gxwork[npt-1] = x[i-1]; gxwork[npt] = x[i-1];
2014 if ((gxwork[npt-1] >= uxmin-rounding && gxwork[npt-1] <= uxmax+rounding) ||
2015 (gxwork[npt] >= uxmin-rounding && gxwork[npt] <= uxmax+rounding)) npt += 2;
2017 gywork[npt-1] = gywork[npt-2];
2018 gxwork[npt-1] = xwmin;
2019 ComputeLogs(npt, optionZ);
2020 gPad->PaintPolyLine(npt,gxworkl,gyworkl,noClip);
2034 if (!optionOne) drawtype = 2;
2039 for (i=first; i<=last;i++) {
2042 gxwork[npt-1] = wmin+(i-first)*delta+0.5*delta;
2044 xi1 = x[i]; xi = x[i-1];
2046 if (i != last) Error(where,
"X must be in increasing order");
2047 else Error(where,
"X must have N+1 values with option N");
2050 gxwork[npt-1] = x[i-1] + 0.5*(x[i]-x[i-1]);
2052 if (gxwork[npt-1] < uxmin || gxwork[npt-1] > uxmax) {
2056 gywork[npt-1] = y[i-1];
2057 ComputeLogs(npt, optionZ);
2058 if ((gyworkl[npt-1] < rwymin) || (gyworkl[npt-1] > rwymax)) {
2060 ComputeLogs(npt, optionZ);
2061 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
2063 gxwork[0] = gxwork[npt-1];
2064 gywork[0] = gywork[npt-1];
2068 if (npt >= fgMaxPointsPerLine) {
2069 ComputeLogs(fgMaxPointsPerLine, optionZ);
2070 Smooth(theGraph, fgMaxPointsPerLine,gxworkl,gyworkl,drawtype);
2071 gxwork[0] = gxwork[npt-1];
2072 gywork[0] = gywork[npt-1];
2077 ComputeLogs(npt, optionZ);
2078 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
2081 drawtype = drawtype+10;
2083 for (i=first; i<=last;i++) {
2086 gywork[npt-1] = wmin+(i-first)*delta+0.5*delta;
2088 yi1 = y[i]; yi = y[i-1];
2090 if (i != last) Error(where,
"Y must be in increasing order");
2091 else Error(where,
"Y must have N+1 values with option N");
2094 gywork[npt-1] = y[i-1] + 0.5*(y[i]-y[i-1]);
2096 gxwork[npt-1] = x[i-1];
2097 ComputeLogs(npt, optionZ);
2098 if ((gxworkl[npt] < uxmin) || (gxworkl[npt] > uxmax)) {
2100 ComputeLogs(npt, optionZ);
2101 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
2103 gxwork[0] = gxwork[npt-1];
2104 gywork[0] = gywork[npt-1];
2108 if (npt >= fgMaxPointsPerLine) {
2109 ComputeLogs(fgMaxPointsPerLine, optionZ);
2110 Smooth(theGraph, fgMaxPointsPerLine,gxworkl,gyworkl,drawtype);
2111 gxwork[0] = gxwork[npt-1];
2112 gywork[0] = gywork[npt-1];
2117 ComputeLogs(npt, optionZ);
2118 Smooth(theGraph, npt,gxworkl,gyworkl,drawtype);
2126 gPad->SetBit(TGraph::kClipFrame);
2127 wminstep = wmin + 0.5*delta;
2128 Axis_t ax1,ax2,ay1,ay2;
2129 gPad->GetRangeAxis(ax1,ay1,ax2,ay2);
2133 for (i=first; i<=last;i++) {
2136 gxwork[npt-1] = wmin+(i-first)*delta+0.5*delta;
2138 xi1 = x[i]; xi = x[i-1];
2140 if (i != last) Error(where,
"X must be in increasing order");
2141 else Error(where,
"X must have N+1 values with option N");
2144 gxwork[npt-1] = x[i-1] + 0.5*(x[i]-x[i-1]);
2146 if (gxwork[npt-1] < uxmin || gxwork[npt-1] > uxmax) { npt--;
continue;}
2147 gywork[npt-1] = y[i-1];
2148 gywork[npt] = y[i-1];
2149 if ((gywork[npt-1] < rwymin) || ((gywork[npt-1] > rwymax) && !optionFill2)) {
2151 ComputeLogs(npt, optionZ);
2152 gPad->PaintPolyLine(npt,gxworkl,gyworkl);
2154 gxwork[0] = gxwork[npt-1];
2155 gywork[0] = gywork[npt-1];
2160 if (npt >= fgMaxPointsPerLine) {
2162 ComputeLogs(fgMaxPointsPerLine, optionZ);
2164 gxworkl[npt] = gxworkl[npt-1]; gyworkl[npt] = rwymin;
2165 gxworkl[npt+1] = gxworkl[0]; gyworkl[npt+1] = rwymin;
2166 gPad->PaintFillArea(fgMaxPointsPerLine+2,gxworkl,gyworkl);
2168 gPad->PaintPolyLine(npt,gxworkl,gyworkl);
2170 gxwork[0] = gxwork[npt-1];
2171 gywork[0] = gywork[npt-1];
2176 ComputeLogs(npt, optionZ);
2178 gxworkl[npt] = gxworkl[npt-1]; gyworkl[npt] = rwymin;
2179 gxworkl[npt+1] = gxworkl[0]; gyworkl[npt+1] = rwymin;
2180 gPad->PaintFillArea(npt+2,gxworkl,gyworkl);
2182 gPad->PaintPolyLine(npt,gxworkl,gyworkl);
2186 for (i=first; i<=last;i++) {
2189 gywork[npt-1] = wminstep+(i-first)*delta+0.5*delta;
2191 yi1 = y[i]; yi = y[i-1];
2193 if (i != last) Error(where,
"Y must be in increasing order");
2194 else Error(where,
"Y must have N+1 values with option N");
2197 gywork[npt-1] = y[i-1] + 0.5*(y[i]-y[i-1]);
2199 gxwork[npt-1] = x[i-1];
2200 if ((gxwork[npt-1] < uxmin) || (gxwork[npt-1] > uxmax)) {
2203 ComputeLogs(npt, optionZ);
2204 gPad->PaintPolyLine(npt,gxworkl,gyworkl,noClip);
2207 gxwork[0] = gxwork[npt-1];
2208 gywork[0] = gywork[npt-1];
2212 if (npt >= fgMaxPointsPerLine) {
2214 ComputeLogs(fgMaxPointsPerLine, optionZ);
2215 gPad->PaintPolyLine(fgMaxPointsPerLine,gxworkl,gyworkl);
2217 gxwork[0] = gxwork[npt-1];
2218 gywork[0] = gywork[npt-1];
2222 if (optionLine != 0 && npt > 1) {
2223 ComputeLogs(npt, optionZ);
2224 gPad->PaintPolyLine(npt,gxworkl,gyworkl,noClip);
2233 offset = delta*baroffset; dbar = delta*barwidth;
2236 offset = (x[1]-x[0])*baroffset;
2237 dbar = (x[1]-x[0])*barwidth;
2239 offset = (y[1]-y[0])*baroffset;
2240 dbar = (y[1]-y[0])*barwidth;
2243 drawbordersav = drawborder;
2244 gStyle->SetDrawBorder(1);
2247 xhigh = wmin+offset+dbar;
2248 if (!optionOne) ylow = TMath::Min(TMath::Max((Double_t)0,gPad->GetUymin())
2250 else ylow = gPad->GetUymin();
2252 for (i=first; i<=last;i++) {
2258 ComputeLogs(2, optionZ);
2259 if (xlow < rwxmax && xhigh > rwxmin)
2260 gPad->PaintBox(gxworkl[0],gyworkl[0],gxworkl[1],gyworkl[1]);
2263 xhigh = xhigh+delta;
2266 xi1 = x[i]; xi = x[i-1];
2268 Error(where,
"X must be in increasing order");
2271 offset = (x[i+1]-x[i])*baroffset;
2272 dbar = (x[i+1]-x[i])*barwidth;
2273 xlow = x[i] + offset;
2274 xhigh = x[i] + offset + dbar;
2279 ylow = wmin + offset;
2280 yhigh = wmin + offset + dbar;
2281 if (!optionOne) xlow = TMath::Max((Double_t)0,gPad->GetUxmin());
2282 else xlow = gPad->GetUxmin();
2283 for (i=first; i<=last;i++) {
2289 ComputeLogs(2, optionZ);
2290 gPad->PaintBox(gxworkl[0],gyworkl[0],gxworkl[1],gyworkl[1]);
2291 gPad->PaintBox(xlow,ylow,xhigh,yhigh);
2293 ylow = ylow + delta;
2294 yhigh = yhigh + delta;
2297 yi1 = y[i]; yi = y[i-1];
2299 Error(where,
"Y must be in increasing order");
2302 offset = (y[i+1]-y[i])*baroffset;
2303 dbar = (y[i+1]-y[i])*barwidth;
2304 ylow = y[i] + offset;
2305 yhigh = y[i] + offset + dbar;
2310 gStyle->SetDrawBorder(drawbordersav);
2316 if ((optionStar) || (optionMark)) optionMarker=1;
2322 for (i=first; i<=last;i++) {
2323 if (!optionBins) xm = wmin+(i-first)*delta+0.5*delta;
2324 else xm = x[i-1] + 0.5*(x[i]-x[i-1]);
2326 if (optionMark != 10) {
2327 if (ym<rwymax && ym > rwymin) {
2333 if (ym<rwymax && ym >= rwymin) {
2339 if (npt >= fgMaxPointsPerLine) {
2340 ComputeLogs(npt, optionZ);
2341 gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
2346 ComputeLogs(npt, optionZ);
2347 gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
2350 wminstep = wmin + 0.5*delta;
2351 for (i=first; i<=last;i++) {
2352 if (!optionBins) ym = wminstep+(i-first)*delta+0.5*delta;
2353 else ym = y[i-1] + 0.5*(y[i]-y[i-1]);
2355 if (optionMark != 10) {
2356 if (xm<rwxmax && xm > rwxmin) {
2362 if (xm<rwxmax && xm >= rwxmin) {
2368 if (npt >= fgMaxPointsPerLine) {
2369 ComputeLogs(npt, optionZ);
2370 gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
2375 ComputeLogs(npt, optionZ);
2376 gPad->PaintPolyMarker(npt,gxworkl,gyworkl);
2381 gPad->ResetBit(TGraph::kClipFrame);
2393 void TGraphPainter::PaintGraphAsymmErrors(TGraph *theGraph, Option_t *option)
2396 Double_t *xline = 0;
2397 Double_t *yline = 0;
2400 Double_t xb[4], yb[4];
2402 const Int_t kBASEMARKER=8;
2403 Double_t s2x, s2y, symbolsize, sbase;
2404 Double_t x, y, xl1, xl2, xr1, xr2, yup1, yup2, ylow1, ylow2, tx, ty;
2405 static Float_t cxx[15] = {1,1,0.6,0.6,1,1,0.6,0.5,1,0.6,0.6,1,0.6,1,1};
2406 static Float_t cyy[15] = {1,1,1,1,1,1,1,1,1,0.5,0.6,1,1,1,1};
2407 Int_t theNpoints = theGraph->GetN();
2408 Double_t *theX = theGraph->GetX();
2409 Double_t *theY = theGraph->GetY();
2410 Double_t *theEXlow = theGraph->GetEXlow();
if (!theEXlow)
return;
2411 Double_t *theEYlow = theGraph->GetEYlow();
if (!theEYlow)
return;
2412 Double_t *theEXhigh = theGraph->GetEXhigh();
if (!theEXhigh)
return;
2413 Double_t *theEYhigh = theGraph->GetEYhigh();
if (!theEYhigh)
return;
2415 if (strchr(option,
'X') || strchr(option,
'x')) {PaintGraphSimple(theGraph, option);
return;}
2416 Bool_t brackets = kFALSE;
2417 Bool_t braticks = kFALSE;
2418 if (strstr(option,
"||") || strstr(option,
"[]")) {
2420 if (strstr(option,
"[]")) braticks = kTRUE;
2422 Bool_t endLines = kTRUE;
2423 if (strchr(option,
'z')) endLines = kFALSE;
2424 if (strchr(option,
'Z')) endLines = kFALSE;
2425 const char *arrowOpt = 0;
2426 if (strchr(option,
'>')) arrowOpt =
">";
2427 if (strstr(option,
"|>")) arrowOpt =
"|>";
2429 Bool_t axis = kFALSE;
2430 if (strchr(option,
'a')) axis = kTRUE;
2431 if (strchr(option,
'A')) axis = kTRUE;
2432 if (axis) PaintGraphSimple(theGraph, option);
2434 Bool_t option0 = kFALSE;
2435 Bool_t option2 = kFALSE;
2436 Bool_t option3 = kFALSE;
2437 Bool_t option4 = kFALSE;
2438 Bool_t option5 = kFALSE;
2439 if (strchr(option,
'0')) option0 = kTRUE;
2440 if (strchr(option,
'2')) option2 = kTRUE;
2441 if (strchr(option,
'3')) option3 = kTRUE;
2442 if (strchr(option,
'4')) {option3 = kTRUE; option4 = kTRUE;}
2443 if (strchr(option,
'5')) {option2 = kTRUE; option5 = kTRUE;}
2446 xline =
new Double_t[2*theNpoints];
2447 yline =
new Double_t[2*theNpoints];
2448 if (!xline || !yline) {
2449 Error(
"Paint",
"too many points, out of memory");
2456 theGraph->TAttLine::Modify();
2459 arrow.SetLineWidth(theGraph->GetLineWidth());
2460 arrow.SetLineColor(theGraph->GetLineColor());
2461 arrow.SetFillColor(theGraph->GetFillColor());
2464 Double_t x1b,y1b,x2b,y2b;
2465 box.SetLineWidth(theGraph->GetLineWidth());
2466 box.SetLineColor(theGraph->GetLineColor());
2467 box.SetFillColor(theGraph->GetFillColor());
2468 box.SetFillStyle(theGraph->GetFillStyle());
2470 symbolsize = theGraph->GetMarkerSize();
2471 sbase = symbolsize*kBASEMARKER;
2472 Int_t mark = theGraph->GetMarkerStyle();
2475 if (mark >= 20 && mark <= 34) {
2481 s2x = gPad->PixeltoX(Int_t(0.5*sbase)) - gPad->PixeltoX(0);
2482 s2y =-gPad->PixeltoY(Int_t(0.5*sbase)) + gPad->PixeltoY(0);
2483 Int_t dxend = Int_t(gStyle->GetEndErrorSize());
2484 tx = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
2485 ty =-gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
2486 Float_t asize = 0.6*symbolsize*kBASEMARKER/gPad->GetWh();
2488 gPad->SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
2489 for (Int_t i=0;i<theNpoints;i++) {
2490 x = gPad->XtoPad(theX[i]);
2491 y = gPad->YtoPad(theY[i]);
2494 if (x < gPad->GetUxmin()) x = gPad->GetUxmin();
2495 if (x > gPad->GetUxmax()) x = gPad->GetUxmax();
2496 if (y < gPad->GetUymin()) y = gPad->GetUymin();
2497 if (y > gPad->GetUymax()) y = gPad->GetUymax();
2499 if (x < gPad->GetUxmin())
continue;
2500 if (x > gPad->GetUxmax())
continue;
2501 if (y < gPad->GetUymin())
continue;
2502 if (y > gPad->GetUymax())
continue;
2506 xl2 = gPad->XtoPad(theX[i] - theEXlow[i]);
2510 x1b = gPad->XtoPad(theX[i] - theEXlow[i]);
2511 y1b = gPad->YtoPad(theY[i] - theEYlow[i]);
2512 x2b = gPad->XtoPad(theX[i] + theEXhigh[i]);
2513 y2b = gPad->YtoPad(theY[i] + theEYhigh[i]);
2514 if (x1b < gPad->GetUxmin()) x1b = gPad->GetUxmin();
2515 if (x1b > gPad->GetUxmax()) x1b = gPad->GetUxmax();
2516 if (y1b < gPad->GetUymin()) y1b = gPad->GetUymin();
2517 if (y1b > gPad->GetUymax()) y1b = gPad->GetUymax();
2518 if (x2b < gPad->GetUxmin()) x2b = gPad->GetUxmin();
2519 if (x2b > gPad->GetUxmax()) x2b = gPad->GetUxmax();
2520 if (y2b < gPad->GetUymin()) y2b = gPad->GetUymin();
2521 if (y2b > gPad->GetUymax()) y2b = gPad->GetUymax();
2522 if (option5) box.PaintBox(x1b, y1b, x2b, y2b,
"l");
2523 else box.PaintBox(x1b, y1b, x2b, y2b);
2531 yline[if1-1] = gPad->YtoPad(theY[i] + theEYhigh[i]);
2532 yline[if2-1] = gPad->YtoPad(theY[i] - theEYlow[i]);
2540 arrow.PaintArrow(xl1,y,xl2,y,asize,arrowOpt);
2542 if (!brackets) gPad->PaintLine(xl1,y,xl2,y);
2545 xb[0] = xl2+tx; yb[0] = y-ty;
2546 xb[1] = xl2; yb[1] = y-ty;
2547 xb[2] = xl2; yb[2] = y+ty;
2548 xb[3] = xl2+tx; yb[3] = y+ty;
2549 gPad->PaintPolyLine(4, xb, yb);
2551 gPad->PaintLine(xl2,y-ty,xl2,y+ty);
2557 xr2 = gPad->XtoPad(theX[i] + theEXhigh[i]);
2560 arrow.PaintArrow(xr1,y,xr2,y,asize,arrowOpt);
2562 if (!brackets) gPad->PaintLine(xr1,y,xr2,y);
2565 xb[0] = xr2-tx; yb[0] = y-ty;
2566 xb[1] = xr2; yb[1] = y-ty;
2567 xb[2] = xr2; yb[2] = y+ty;
2568 xb[3] = xr2-tx; yb[3] = y+ty;
2569 gPad->PaintPolyLine(4, xb, yb);
2571 gPad->PaintLine(xr2,y-ty,xr2,y+ty);
2577 yup2 = gPad->YtoPad(theY[i] + theEYhigh[i]);
2578 if (yup2 > gPad->GetUymax()) yup2 = gPad->GetUymax();
2581 arrow.PaintArrow(x,yup1,x,yup2,asize,arrowOpt);
2583 if (!brackets) gPad->PaintLine(x,yup1,x,yup2);
2586 xb[0] = x-tx; yb[0] = yup2-ty;
2587 xb[1] = x-tx; yb[1] = yup2;
2588 xb[2] = x+tx; yb[2] = yup2;
2589 xb[3] = x+tx; yb[3] = yup2-ty;
2590 gPad->PaintPolyLine(4, xb, yb);
2592 gPad->PaintLine(x-tx,yup2,x+tx,yup2);
2598 ylow2 = gPad->YtoPad(theY[i] - theEYlow[i]);
2599 if (ylow2 < gPad->GetUymin()) ylow2 = gPad->GetUymin();
2600 if (ylow2 < ylow1) {
2602 arrow.PaintArrow(x,ylow1,x,ylow2,asize,arrowOpt);
2604 if (!brackets) gPad->PaintLine(x,ylow1,x,ylow2);
2607 xb[0] = x-tx; yb[0] = ylow2+ty;
2608 xb[1] = x-tx; yb[1] = ylow2;
2609 xb[2] = x+tx; yb[2] = ylow2;
2610 xb[3] = x+tx; yb[3] = ylow2+ty;
2611 gPad->PaintPolyLine(4, xb, yb);
2613 gPad->PaintLine(x-tx,ylow2,x+tx,ylow2);
2619 if (!brackets && !axis) PaintGraphSimple(theGraph, option);
2620 gPad->ResetBit(TGraph::kClipFrame);
2623 Int_t logx = gPad->GetLogx();
2624 Int_t logy = gPad->GetLogy();
2627 if (option4) PaintGraph(theGraph, 2*theNpoints, xline, yline,
"FC");
2628 else PaintGraph(theGraph, 2*theNpoints, xline, yline,
"F");
2629 gPad->SetLogx(logx);
2630 gPad->SetLogy(logy);
2639 void TGraphPainter::PaintGraphMultiErrors(TGraph *theGraph, Option_t *option)
2641 if (!theGraph->InheritsFrom(TGraphMultiErrors::Class())) {
2642 PaintHelper(theGraph, option);
2646 auto tg = (TGraphMultiErrors *)theGraph;
2648 Int_t NYErrors = tg->GetNYErrors();
2649 if (NYErrors <= 0) {
2650 PaintGraphSimple(tg, option);
2654 TString tsOpt = option;
2657 std::vector<TString> options(NYErrors + 1);
2660 if (tsOpt.CountChar(
';') < NYErrors) {
2661 options[0] = tsOpt.Contains(
";") ? tsOpt(0, tsOpt.First(
';')) : tsOpt.Copy();
2665 Ssiz_t firstSemicolon;
2666 while ((firstSemicolon = tsOpt.First(
';')) != kNPOS && filled <= NYErrors) {
2667 options[filled] = tsOpt(0, firstSemicolon);
2668 tsOpt = tsOpt(firstSemicolon + 1, tsOpt.Length());
2672 if (filled <= NYErrors) {
2673 options[filled] = tsOpt.Copy();
2677 for (Int_t i = filled; i <= NYErrors; i++)
2680 Double_t *xline =
nullptr;
2681 std::vector<Double_t *> yline(NYErrors);
2684 Double_t xb[4], yb[4];
2686 const Int_t kBASEMARKER = 8;
2687 Double_t s2x, s2y, symbolsize, sbase;
2688 Double_t x, y, xl1, xl2, xr1, xr2, yup1, yup2, ylow1, ylow2, tx, ty;
2689 static Float_t cxx[15] = {1., 1., 0.6, 0.6, 1., 1., 0.6, 0.5, 1., 0.6, 0.6, 1., 0.6, 1., 1.};
2690 static Float_t cyy[15] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 0.5, 0.6, 1., 1., 1., 1.};
2691 Int_t theNpoints = tg->GetN();
2692 Double_t *theX = tg->GetX();
2693 Double_t *theY = tg->GetY();
2694 Double_t *theExL = tg->GetEXlow();
2695 Double_t *theExH = tg->GetEXhigh();
2696 std::vector<Double_t *> theEyL(NYErrors);
2697 std::vector<Double_t *> theEyH(NYErrors);
2699 Bool_t theEyExists = kTRUE;
2700 for (Int_t j = 0; j < NYErrors; j++) {
2701 theEyL[j] = tg->GetEYlow(j);
2702 theEyH[j] = tg->GetEYhigh(j);
2703 theEyExists &= (theEyL[j] && theEyH[j]);
2706 if (!theX || !theY || !theExL || !theExH || !theEyExists)
2709 std::vector<Bool_t> DrawErrors(NYErrors);
2710 Bool_t AnyErrors = kFALSE;
2711 Bool_t NoErrorsX = kTRUE;
2712 Bool_t Option0X = kFALSE;
2713 Bool_t DrawMarker = kFALSE;
2714 std::vector<Bool_t> Braticks(NYErrors);
2715 std::vector<Bool_t> Brackets(NYErrors);
2716 std::vector<Bool_t> EndLines(NYErrors);
2717 std::vector<Char_t *> ArrowOpt(NYErrors);
2718 std::vector<Bool_t> Option5(NYErrors);
2719 std::vector<Bool_t> Option4(NYErrors);
2720 std::vector<Bool_t> Option3(NYErrors);
2721 Bool_t AnyOption3 = kFALSE;
2722 std::vector<Bool_t> Option2(NYErrors);
2723 std::vector<Bool_t> Option0(NYErrors);
2724 Bool_t AnyOption0 = kFALSE;
2725 std::vector<Double_t> Scale(NYErrors);
2727 const TRegexp ScaleRegExp(
"s=*[0-9]\\.*[0-9]");
2729 for (Int_t j = 0; j < NYErrors; j++) {
2730 if (options[j + 1].Contains(
"s=")) {
2731 sscanf(strstr(options[j + 1].Data(),
"s="),
"s=%lf", &Scale[j]);
2732 options[j + 1].ReplaceAll(options[j + 1](ScaleRegExp),
"");
2736 DrawErrors[j] = !options[j + 1].Contains(
"x");
2737 AnyErrors |= DrawErrors[j];
2738 Braticks[j] = options[j + 1].Contains(
"[]");
2739 Brackets[j] = options[j + 1].Contains(
"||") || Braticks[j];
2740 EndLines[j] = !options[j + 1].Contains(
"z");
2742 if (options[j + 1].Contains(
"|>"))
2743 ArrowOpt[j] = (Char_t *)
"|>";
2744 else if (options[j + 1].Contains(
">"))
2745 ArrowOpt[j] = (Char_t *)
">";
2747 ArrowOpt[j] =
nullptr;
2749 Option5[j] = options[j + 1].Contains(
"5");
2750 Option4[j] = options[j + 1].Contains(
"4");
2751 Option3[j] = options[j + 1].Contains(
"3") || Option4[j];
2752 AnyOption3 |= Option3[j];
2753 Option2[j] = options[j + 1].Contains(
"2") || Option5[j];
2754 Option0[j] = options[j + 1].Contains(
"0");
2755 AnyOption0 |= Option0[j];
2757 NoErrorsX &= (Option3[j] || Option2[j]);
2758 Option0X |= !(Option3[j] || Option2[j]) && Option0[j];
2759 DrawMarker |= !(Brackets[j] || Option3[j] || Option2[j]);
2762 Bool_t Draw0PointsX = !options[0].Contains(
"x0") && (gPad->GetLogx() == 0);
2763 Bool_t Draw0PointsY = !options[0].Contains(
"y0") && (gPad->GetLogy() == 0);
2764 options[0].ReplaceAll(
"x0",
"");
2765 options[0].ReplaceAll(
"y0",
"");
2767 Bool_t DrawErrorsX = !options[0].Contains(
"x");
2768 Bool_t BraticksX = options[0].Contains(
"[]");
2769 Bool_t BracketsX = options[0].Contains(
"||") || BraticksX;
2770 Bool_t EndLinesX = !options[0].Contains(
"z");
2772 Char_t *ArrowOptX =
nullptr;
2773 if (options[0].Contains(
"|>"))
2774 ArrowOptX = (Char_t *)
"|>";
2775 else if (options[0].Contains(
">"))
2776 ArrowOptX = (Char_t *)
">";
2778 Double_t ScaleX = 1.;
2779 if (options[0].Contains(
"s=")) {
2780 sscanf(strstr(options[0].Data(),
"s="),
"s=%lf", &ScaleX);
2781 options[0].ReplaceAll(options[0](ScaleRegExp),
"");
2784 if (!AnyErrors && !DrawErrorsX) {
2785 PaintGraphSimple(tg, options[0].Data());
2789 Bool_t DrawAxis = options[0].Contains(
"a");
2790 Bool_t IndividualStyles = options[0].Contains(
"s");
2793 PaintGraphSimple(tg, options[0].Data());
2795 Int_t NPointsInside = AnyOption0 ? theNpoints : 0;
2797 for (Int_t i = 0; i < theNpoints && !AnyOption0; i++) {
2798 x = gPad->XtoPad(theX[i]);
2799 y = gPad->YtoPad(theY[i]);
2801 if ((x >= gPad->GetUxmin()) && (x <= gPad->GetUxmax()) && (y >= gPad->GetUymin()) && (y <= gPad->GetUymax()) &&
2802 (Draw0PointsX || theX[i] != 0.) && (Draw0PointsY || theY[i] != 0.))
2807 xline =
new Double_t[2 * NPointsInside];
2810 Error(
"Paint",
"too many points, out of memory");
2815 if2 = 2 * NPointsInside;
2818 for (Int_t j = 0; j < NYErrors; j++) {
2819 if (Option3[j] && DrawErrors[j]) {
2820 yline[j] =
new Double_t[2 * NPointsInside];
2823 Error(
"Paint",
"too many points, out of memory");
2825 for (Int_t k = 0; k < j; k++)
2833 tg->TAttLine::Modify();
2836 arrow.SetLineWidth(tg->GetLineWidth());
2837 arrow.SetLineColor(tg->GetLineColor());
2838 arrow.SetFillColor(tg->GetFillColor());
2841 Double_t x1b, y1b, x2b, y2b;
2842 box.SetLineWidth(tg->GetLineWidth());
2843 box.SetLineColor(tg->GetLineColor());
2844 box.SetFillColor(tg->GetFillColor());
2845 box.SetFillStyle(tg->GetFillStyle());
2847 symbolsize = tg->GetMarkerSize();
2848 sbase = symbolsize * kBASEMARKER;
2849 Int_t mark = tg->GetMarkerStyle();
2853 if (mark >= 20 && mark <= 34) {
2854 cx = cxx[mark - 20];
2855 cy = cyy[mark - 20];
2859 s2x = gPad->PixeltoX(Int_t(0.5 * sbase)) - gPad->PixeltoX(0);
2860 s2y = -gPad->PixeltoY(Int_t(0.5 * sbase)) + gPad->PixeltoY(0);
2861 auto dxend = Int_t(gStyle->GetEndErrorSize());
2862 tx = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
2863 ty = -gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
2864 Float_t asize = 0.6 * symbolsize * kBASEMARKER / gPad->GetWh();
2866 gPad->SetBit(TGraph::kClipFrame, tg->TestBit(TGraph::kClipFrame));
2868 for (Int_t i = 0; i < theNpoints; i++) {
2869 x = gPad->XtoPad(theX[i]);
2870 y = gPad->YtoPad(theY[i]);
2873 (x < gPad->GetUxmin()) || (x > gPad->GetUxmax()) || (y < gPad->GetUymin()) || (y > gPad->GetUymax());
2875 if ((isOutside && !AnyOption0) || (!Draw0PointsX && theX[i] == 0.) || (!Draw0PointsY && theY[i] == 0.))
2880 if (x < gPad->GetUxmin())
2881 x = gPad->GetUxmin();
2882 if (x > gPad->GetUxmax())
2883 x = gPad->GetUxmax();
2884 if (y < gPad->GetUymin())
2885 y = gPad->GetUymin();
2886 if (y > gPad->GetUymax())
2887 y = gPad->GetUymax();
2897 for (Int_t j = 0; j < NYErrors; j++) {
2902 if (Option2[j] && (!isOutside || Option0[j])) {
2903 if (IndividualStyles) {
2904 box.SetLineWidth(tg->GetLineWidth(j));
2905 box.SetLineColor(tg->GetLineColor(j));
2906 box.SetFillColor(tg->GetFillColor(j));
2907 box.SetFillStyle(tg->GetFillStyle(j));
2910 x1b = gPad->XtoPad(theX[i] - Scale[j] * theExL[i]);
2911 y1b = gPad->YtoPad(theY[i] - theEyL[j][i]);
2912 x2b = gPad->XtoPad(theX[i] + Scale[j] * theExH[i]);
2913 y2b = gPad->YtoPad(theY[i] + theEyH[j][i]);
2914 if (x1b < gPad->GetUxmin())
2915 x1b = gPad->GetUxmin();
2916 if (x1b > gPad->GetUxmax())
2917 x1b = gPad->GetUxmax();
2918 if (y1b < gPad->GetUymin())
2919 y1b = gPad->GetUymin();
2920 if (y1b > gPad->GetUymax())
2921 y1b = gPad->GetUymax();
2922 if (x2b < gPad->GetUxmin())
2923 x2b = gPad->GetUxmin();
2924 if (x2b > gPad->GetUxmax())
2925 x2b = gPad->GetUxmax();
2926 if (y2b < gPad->GetUymin())
2927 y2b = gPad->GetUymin();
2928 if (y2b > gPad->GetUymax())
2929 y2b = gPad->GetUymax();
2931 box.PaintBox(x1b, y1b, x2b, y2b,
"l");
2933 box.PaintBox(x1b, y1b, x2b, y2b);
2938 if (!isOutside || Option0[j]) {
2939 yline[j][if1 - 2] = gPad->YtoPad(theY[i] + theEyH[j][i]);
2940 yline[j][if2] = gPad->YtoPad(theY[i] - theEyL[j][i]);
2942 yline[j][if1 - 2] = gPad->GetUymin();
2943 yline[j][if2] = gPad->GetUymin();
2947 if (IndividualStyles) {
2948 tg->GetAttLine(j)->Modify();
2950 arrow.SetLineWidth(tg->GetLineWidth(j));
2951 arrow.SetLineColor(tg->GetLineColor(j));
2952 arrow.SetFillColor(tg->GetFillColor(j));
2955 ylow1 = y - s2y * cy;
2956 ylow2 = gPad->YtoPad(theY[i] - theEyL[j][i]);
2957 if (ylow2 < gPad->GetUymin())
2958 ylow2 = gPad->GetUymin();
2959 if (ylow2 < ylow1 && DrawErrors[j] && !Option2[j] && !Option3[j] && (!isOutside || Option0[j])) {
2961 arrow.PaintArrow(x, ylow1, x, ylow2, asize, ArrowOpt[j]);
2964 gPad->PaintLine(x, ylow1, x, ylow2);
2975 gPad->PaintPolyLine(4, xb, yb);
2977 gPad->PaintLine(x - tx, ylow2, x + tx, ylow2);
2982 yup1 = y + s2y * cy;
2983 yup2 = gPad->YtoPad(theY[i] + theEyH[j][i]);
2984 if (yup2 > gPad->GetUymax())
2985 yup2 = gPad->GetUymax();
2986 if (yup2 > yup1 && DrawErrors[j] && !Option2[j] && !Option3[j] && (!isOutside || Option0[j])) {
2988 arrow.PaintArrow(x, yup1, x, yup2, asize, ArrowOpt[j]);
2991 gPad->PaintLine(x, yup1, x, yup2);
3002 gPad->PaintPolyLine(4, xb, yb);
3004 gPad->PaintLine(x - tx, yup2, x + tx, yup2);
3011 if (IndividualStyles) {
3012 tg->TAttLine::Modify();
3014 arrow.SetLineWidth(tg->GetLineWidth());
3015 arrow.SetLineColor(tg->GetLineColor());
3016 arrow.SetFillColor(tg->GetFillColor());
3020 xl2 = gPad->XtoPad(theX[i] - ScaleX * theExL[i]);
3021 if (xl1 > xl2 && !NoErrorsX && (!isOutside || Option0X)) {
3023 arrow.PaintArrow(xl1, y, xl2, y, asize, ArrowOptX);
3026 gPad->PaintLine(xl1, y, xl2, y);
3037 gPad->PaintPolyLine(4, xb, yb);
3039 gPad->PaintLine(xl2, y - ty, xl2, y + ty);
3045 xr2 = gPad->XtoPad(theX[i] + ScaleX * theExH[i]);
3046 if (xr1 < xr2 && !NoErrorsX && (!isOutside || Option0X)) {
3048 arrow.PaintArrow(xr1, y, xr2, y, asize, ArrowOptX);
3051 gPad->PaintLine(xr1, y, xr2, y);
3062 gPad->PaintPolyLine(4, xb, yb);
3064 gPad->PaintLine(xr2, y - ty, xr2, y + ty);
3071 if (DrawMarker && !DrawAxis)
3072 PaintGraphSimple(tg, options[0].Data());
3073 gPad->ResetBit(TGraph::kClipFrame);
3075 auto tgDummy =
new TGraph();
3076 tg->TAttFill::Copy(*tgDummy);
3077 tg->TAttLine::Copy(*tgDummy);
3078 tg->TAttMarker::Copy(*tgDummy);
3080 for (Int_t j = 0; j < NYErrors; j++) {
3081 if (Option3[j] && DrawErrors[j]) {
3082 if (IndividualStyles) {
3083 tg->GetAttFill(j)->Copy(*tgDummy);
3084 tg->GetAttLine(j)->Copy(*tgDummy);
3087 Int_t logx = gPad->GetLogx();
3088 Int_t logy = gPad->GetLogy();
3092 PaintGraph(tgDummy, 2 * NPointsInside, xline, yline[j],
"FC");
3094 PaintGraph(tgDummy, 2 * NPointsInside, xline, yline[j],
"F");
3095 gPad->SetLogx(logx);
3096 gPad->SetLogy(logy);
3110 void TGraphPainter::PaintGraphBentErrors(TGraph *theGraph, Option_t *option)
3113 Double_t *xline = 0;
3114 Double_t *yline = 0;
3117 Double_t xb[4], yb[4];
3119 const Int_t kBASEMARKER=8;
3120 Double_t s2x, s2y, symbolsize, sbase;
3121 Double_t x, y, xl1, xl2, xr1, xr2, yup1, yup2, ylow1, ylow2, tx, ty;
3122 Double_t bxl, bxh, byl, byh;
3123 static Float_t cxx[15] = {1,1,0.6,0.6,1,1,0.6,0.5,1,0.6,0.6,1,0.6,1,1};
3124 static Float_t cyy[15] = {1,1,1,1,1,1,1,1,1,0.5,0.6,1,1,1,1};
3125 Int_t theNpoints = theGraph->GetN();
3126 Double_t *theX = theGraph->GetX();
3127 Double_t *theY = theGraph->GetY();
3128 Double_t *theEXlow = theGraph->GetEXlow();
if (!theEXlow)
return;
3129 Double_t *theEYlow = theGraph->GetEYlow();
if (!theEYlow)
return;
3130 Double_t *theEXhigh = theGraph->GetEXhigh();
if (!theEXhigh)
return;
3131 Double_t *theEYhigh = theGraph->GetEYhigh();
if (!theEYhigh)
return;
3132 Double_t *theEXlowd = theGraph->GetEXlowd();
if (!theEXlowd)
return;
3133 Double_t *theEXhighd = theGraph->GetEXhighd();
if (!theEXhighd)
return;
3134 Double_t *theEYlowd = theGraph->GetEYlowd();
if (!theEYlowd)
return;
3135 Double_t *theEYhighd = theGraph->GetEYhighd();
if (!theEYhighd)
return;
3137 if (strchr(option,
'X') || strchr(option,
'x')) {PaintGraphSimple(theGraph, option);
return;}
3138 Bool_t brackets = kFALSE;
3139 Bool_t braticks = kFALSE;
3140 if (strstr(option,
"||") || strstr(option,
"[]")) {
3142 if (strstr(option,
"[]")) braticks = kTRUE;
3144 Bool_t endLines = kTRUE;
3145 if (strchr(option,
'z')) endLines = kFALSE;
3146 if (strchr(option,
'Z')) endLines = kFALSE;
3147 const char *arrowOpt = 0;
3148 if (strchr(option,
'>')) arrowOpt =
">";
3149 if (strstr(option,
"|>")) arrowOpt =
"|>";
3151 Bool_t axis = kFALSE;
3152 if (strchr(option,
'a')) axis = kTRUE;
3153 if (strchr(option,
'A')) axis = kTRUE;
3154 if (axis) PaintGraphSimple(theGraph,option);
3156 Bool_t option0 = kFALSE;
3157 Bool_t option2 = kFALSE;
3158 Bool_t option3 = kFALSE;
3159 Bool_t option4 = kFALSE;
3160 Bool_t option5 = kFALSE;
3161 if (strchr(option,
'0')) option0 = kTRUE;
3162 if (strchr(option,
'2')) option2 = kTRUE;
3163 if (strchr(option,
'3')) option3 = kTRUE;
3164 if (strchr(option,
'4')) {option3 = kTRUE; option4 = kTRUE;}
3165 if (strchr(option,
'5')) {option2 = kTRUE; option5 = kTRUE;}
3168 xline =
new Double_t[2*theNpoints];
3169 yline =
new Double_t[2*theNpoints];
3170 if (!xline || !yline) {
3171 Error(
"Paint",
"too many points, out of memory");
3178 theGraph->TAttLine::Modify();
3181 arrow.SetLineWidth(theGraph->GetLineWidth());
3182 arrow.SetLineColor(theGraph->GetLineColor());
3183 arrow.SetFillColor(theGraph->GetFillColor());
3186 Double_t x1b,y1b,x2b,y2b;
3187 box.SetLineWidth(theGraph->GetLineWidth());
3188 box.SetLineColor(theGraph->GetLineColor());
3189 box.SetFillColor(theGraph->GetFillColor());
3190 box.SetFillStyle(theGraph->GetFillStyle());
3192 symbolsize = theGraph->GetMarkerSize();
3193 sbase = symbolsize*kBASEMARKER;
3194 Int_t mark = theGraph->GetMarkerStyle();
3197 if (mark >= 20 && mark <= 34) {
3203 s2x = gPad->PixeltoX(Int_t(0.5*sbase)) - gPad->PixeltoX(0);
3204 s2y =-gPad->PixeltoY(Int_t(0.5*sbase)) + gPad->PixeltoY(0);
3205 Int_t dxend = Int_t(gStyle->GetEndErrorSize());
3206 tx = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
3207 ty =-gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
3208 Float_t asize = 0.6*symbolsize*kBASEMARKER/gPad->GetWh();
3210 gPad->SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
3211 for (Int_t i=0;i<theNpoints;i++) {
3212 x = gPad->XtoPad(theX[i]);
3213 y = gPad->YtoPad(theY[i]);
3214 bxl = gPad->YtoPad(theY[i]+theEXlowd[i]);
3215 bxh = gPad->YtoPad(theY[i]+theEXhighd[i]);
3216 byl = gPad->XtoPad(theX[i]+theEYlowd[i]);
3217 byh = gPad->XtoPad(theX[i]+theEYhighd[i]);
3220 if (x < gPad->GetUxmin()) x = gPad->GetUxmin();
3221 if (x > gPad->GetUxmax()) x = gPad->GetUxmax();
3222 if (y < gPad->GetUymin()) y = gPad->GetUymin();
3223 if (y > gPad->GetUymax()) y = gPad->GetUymax();
3225 if (x < gPad->GetUxmin())
continue;
3226 if (x > gPad->GetUxmax())
continue;
3227 if (y < gPad->GetUymin())
continue;
3228 if (y > gPad->GetUymax())
continue;
3234 x1b = gPad->XtoPad(theX[i] - theEXlow[i]);
3235 y1b = gPad->YtoPad(theY[i] - theEYlow[i]);
3236 x2b = gPad->XtoPad(theX[i] + theEXhigh[i]);
3237 y2b = gPad->YtoPad(theY[i] + theEYhigh[i]);
3238 if (x1b < gPad->GetUxmin()) x1b = gPad->GetUxmin();
3239 if (x1b > gPad->GetUxmax()) x1b = gPad->GetUxmax();
3240 if (y1b < gPad->GetUymin()) y1b = gPad->GetUymin();
3241 if (y1b > gPad->GetUymax()) y1b = gPad->GetUymax();
3242 if (x2b < gPad->GetUxmin()) x2b = gPad->GetUxmin();
3243 if (x2b > gPad->GetUxmax()) x2b = gPad->GetUxmax();
3244 if (y2b < gPad->GetUymin()) y2b = gPad->GetUymin();
3245 if (y2b > gPad->GetUymax()) y2b = gPad->GetUymax();
3246 if (option5) box.PaintBox(x1b, y1b, x2b, y2b,
"l");
3247 else box.PaintBox(x1b, y1b, x2b, y2b);
3255 yline[if1-1] = gPad->YtoPad(theY[i] + theEYhigh[i]);
3256 yline[if2-1] = gPad->YtoPad(theY[i] - theEYlow[i]);
3263 xl2 = gPad->XtoPad(theX[i] - theEXlow[i]);
3266 arrow.PaintArrow(xl1,y,xl2,bxl,asize,arrowOpt);
3268 if (!brackets) gPad->PaintLine(xl1,y,xl2,bxl);
3271 xb[0] = xl2+tx; yb[0] = bxl-ty;
3272 xb[1] = xl2; yb[1] = bxl-ty;
3273 xb[2] = xl2; yb[2] = bxl+ty;
3274 xb[3] = xl2+tx; yb[3] = bxl+ty;
3275 gPad->PaintPolyLine(4, xb, yb);
3277 gPad->PaintLine(xl2,bxl-ty,xl2,bxl+ty);
3283 xr2 = gPad->XtoPad(theX[i] + theEXhigh[i]);
3286 arrow.PaintArrow(xr1,y,xr2,bxh,asize,arrowOpt);
3288 if (!brackets) gPad->PaintLine(xr1,y,xr2,bxh);
3291 xb[0] = xr2-tx; yb[0] = bxh-ty;
3292 xb[1] = xr2; yb[1] = bxh-ty;
3293 xb[2] = xr2; yb[2] = bxh+ty;
3294 xb[3] = xr2-tx; yb[3] = bxh+ty;
3295 gPad->PaintPolyLine(4, xb, yb);
3297 gPad->PaintLine(xr2,bxh-ty,xr2,bxh+ty);
3303 yup2 = gPad->YtoPad(theY[i] + theEYhigh[i]);
3304 if (yup2 > gPad->GetUymax()) yup2 = gPad->GetUymax();
3307 arrow.PaintArrow(x,yup1,byh,yup2,asize,arrowOpt);
3309 if (!brackets) gPad->PaintLine(x,yup1,byh,yup2);
3312 xb[0] = byh-tx; yb[0] = yup2-ty;
3313 xb[1] = byh-tx; yb[1] = yup2;
3314 xb[2] = byh+tx; yb[2] = yup2;
3315 xb[3] = byh+tx; yb[3] = yup2-ty;
3316 gPad->PaintPolyLine(4, xb, yb);
3318 gPad->PaintLine(byh-tx,yup2,byh+tx,yup2);
3324 ylow2 = gPad->YtoPad(theY[i] - theEYlow[i]);
3325 if (ylow2 < gPad->GetUymin()) ylow2 = gPad->GetUymin();
3326 if (ylow2 < ylow1) {
3328 arrow.PaintArrow(x,ylow1,byl,ylow2,asize,arrowOpt);
3330 if (!brackets) gPad->PaintLine(x,ylow1,byl,ylow2);
3333 xb[0] = byl-tx; yb[0] = ylow2+ty;
3334 xb[1] = byl-tx; yb[1] = ylow2;
3335 xb[2] = byl+tx; yb[2] = ylow2;
3336 xb[3] = byl+tx; yb[3] = ylow2+ty;
3337 gPad->PaintPolyLine(4, xb, yb);
3339 gPad->PaintLine(byl-tx,ylow2,byl+tx,ylow2);
3345 if (!brackets && !axis) PaintGraphSimple(theGraph, option);
3346 gPad->ResetBit(TGraph::kClipFrame);
3349 Int_t logx = gPad->GetLogx();
3350 Int_t logy = gPad->GetLogy();
3353 if (option4) PaintGraph(theGraph, 2*theNpoints, xline, yline,
"FC");
3354 else PaintGraph(theGraph, 2*theNpoints, xline, yline,
"F");
3355 gPad->SetLogx(logx);
3356 gPad->SetLogy(logy);
3366 void TGraphPainter::PaintGraphErrors(TGraph *theGraph, Option_t *option)
3369 Double_t *xline = 0;
3370 Double_t *yline = 0;
3373 Double_t xb[4], yb[4];
3375 const Int_t kBASEMARKER=8;
3376 Double_t s2x, s2y, symbolsize, sbase;
3377 Double_t x, y, ex, ey, xl1, xl2, xr1, xr2, yup1, yup2, ylow1, ylow2, tx, ty;
3378 static Float_t cxx[15] = {1,1,0.6,0.6,1,1,0.6,0.5,1,0.6,0.6,1,0.6,1,1};
3379 static Float_t cyy[15] = {1,1,1,1,1,1,1,1,1,0.5,0.6,1,1,1,1};
3380 Int_t theNpoints = theGraph->GetN();
3381 Double_t *theX = theGraph->GetX();
3382 Double_t *theY = theGraph->GetY();
3383 Double_t *theEX = theGraph->GetEX();
if (!theEX)
return;
3384 Double_t *theEY = theGraph->GetEY();
if (!theEY)
return;
3386 if (strchr(option,
'X') || strchr(option,
'x')) {PaintGraphSimple(theGraph, option);
return;}
3387 Bool_t brackets = kFALSE;
3388 Bool_t braticks = kFALSE;
3389 if (strstr(option,
"||") || strstr(option,
"[]")) {
3391 if (strstr(option,
"[]")) braticks = kTRUE;
3393 Bool_t endLines = kTRUE;
3394 if (strchr(option,
'z')) endLines = kFALSE;
3395 if (strchr(option,
'Z')) endLines = kFALSE;
3396 const char *arrowOpt = 0;
3397 if (strchr(option,
'>')) arrowOpt =
">";
3398 if (strstr(option,
"|>")) arrowOpt =
"|>";
3400 Bool_t axis = kFALSE;
3401 if (strchr(option,
'a')) axis = kTRUE;
3402 if (strchr(option,
'A')) axis = kTRUE;
3403 if (axis) PaintGraphSimple(theGraph, option);
3405 Bool_t option0 = kFALSE;
3406 Bool_t option2 = kFALSE;
3407 Bool_t option3 = kFALSE;
3408 Bool_t option4 = kFALSE;
3409 Bool_t option5 = kFALSE;
3410 if (strchr(option,
'0')) option0 = kTRUE;
3411 if (strchr(option,
'2')) option2 = kTRUE;
3412 if (strchr(option,
'3')) option3 = kTRUE;
3413 if (strchr(option,
'4')) {option3 = kTRUE; option4 = kTRUE;}
3414 if (strchr(option,
'5')) {option2 = kTRUE; option5 = kTRUE;}
3417 xline =
new Double_t[2*theNpoints];
3418 yline =
new Double_t[2*theNpoints];
3419 if (!xline || !yline) {
3420 Error(
"Paint",
"too many points, out of memory");
3427 theGraph->TAttLine::Modify();
3430 arrow.SetLineWidth(theGraph->GetLineWidth());
3431 arrow.SetLineColor(theGraph->GetLineColor());
3432 arrow.SetFillColor(theGraph->GetFillColor());
3435 Double_t x1b,y1b,x2b,y2b;
3436 box.SetLineWidth(theGraph->GetLineWidth());
3437 box.SetLineColor(theGraph->GetLineColor());
3438 box.SetFillColor(theGraph->GetFillColor());
3439 box.SetFillStyle(theGraph->GetFillStyle());
3441 symbolsize = theGraph->GetMarkerSize();
3442 sbase = symbolsize*kBASEMARKER;
3443 Int_t mark = theGraph->GetMarkerStyle();
3446 if (mark >= 20 && mark <= 34) {
3452 s2x = gPad->PixeltoX(Int_t(0.5*sbase)) - gPad->PixeltoX(0);
3453 s2y =-gPad->PixeltoY(Int_t(0.5*sbase)) + gPad->PixeltoY(0);
3454 Int_t dxend = Int_t(gStyle->GetEndErrorSize());
3455 tx = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
3456 ty =-gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
3457 Float_t asize = 0.6*symbolsize*kBASEMARKER/gPad->GetWh();
3459 gPad->SetBit(TGraph::kClipFrame, theGraph->TestBit(TGraph::kClipFrame));
3460 for (Int_t i=0;i<theNpoints;i++) {
3461 x = gPad->XtoPad(theX[i]);
3462 y = gPad->YtoPad(theY[i]);
3465 if (x < gPad->GetUxmin()) x = gPad->GetUxmin();
3466 if (x > gPad->GetUxmax()) x = gPad->GetUxmax();
3467 if (y < gPad->GetUymin()) y = gPad->GetUymin();
3468 if (y > gPad->GetUymax()) y = gPad->GetUymax();
3470 if (x < gPad->GetUxmin())
continue;
3471 if (x > gPad->GetUxmax())
continue;
3472 if (y < gPad->GetUymin())
continue;
3473 if (y > gPad->GetUymax())
continue;
3481 x1b = gPad->XtoPad(theX[i] - ex);
3482 y1b = gPad->YtoPad(theY[i] - ey);
3483 x2b = gPad->XtoPad(theX[i] + ex);
3484 y2b = gPad->YtoPad(theY[i] + ey);
3485 if (x1b < gPad->GetUxmin()) x1b = gPad->GetUxmin();
3486 if (x1b > gPad->GetUxmax()) x1b = gPad->GetUxmax();
3487 if (y1b < gPad->GetUymin()) y1b = gPad->GetUymin();
3488 if (y1b > gPad->GetUymax()) y1b = gPad->GetUymax();
3489 if (x2b < gPad->GetUxmin()) x2b = gPad->GetUxmin();
3490 if (x2b > gPad->GetUxmax()) x2b = gPad->GetUxmax();
3491 if (y2b < gPad->GetUymin()) y2b = gPad->GetUymin();
3492 if (y2b > gPad->GetUymax()) y2b = gPad->GetUymax();
3493 if (option5) box.PaintBox(x1b, y1b, x2b, y2b,
"l");
3494 else box.PaintBox(x1b, y1b, x2b, y2b);
3502 yline[if1-1] = gPad->YtoPad(theY[i] + ey);
3503 yline[if2-1] = gPad->YtoPad(theY[i] - ey);
3510 xl2 = gPad->XtoPad(theX[i] - ex);
3513 arrow.PaintArrow(xl1,y,xl2,y,asize,arrowOpt);
3515 if (!brackets) gPad->PaintLine(xl1,y,xl2,y);
3518 xb[0] = xl2+tx; yb[0] = y-ty;
3519 xb[1] = xl2; yb[1] = y-ty;
3520 xb[2] = xl2; yb[2] = y+ty;
3521 xb[3] = xl2+tx; yb[3] = y+ty;
3522 gPad->PaintPolyLine(4, xb, yb);
3524 gPad->PaintLine(xl2,y-ty,xl2,y+ty);
3530 xr2 = gPad->XtoPad(theX[i] + ex);
3533 arrow.PaintArrow(xr1,y,xr2,y,asize,arrowOpt);
3535 if (!brackets) gPad->PaintLine(xr1,y,xr2,y);
3538 xb[0] = xr2-tx; yb[0] = y-ty;
3539 xb[1] = xr2; yb[1] = y-ty;
3540 xb[2] = xr2; yb[2] = y+ty;
3541 xb[3] = xr2-tx; yb[3] = y+ty;
3542 gPad->PaintPolyLine(4, xb, yb);
3544 gPad->PaintLine(xr2,y-ty,xr2,y+ty);
3550 yup2 = gPad->YtoPad(theY[i] + ey);
3551 if (yup2 > gPad->GetUymax()) yup2 = gPad->GetUymax();
3554 arrow.PaintArrow(x,yup1,x,yup2,asize,arrowOpt);
3556 if (!brackets) gPad->PaintLine(x,yup1,x,yup2);
3559 xb[0] = x-tx; yb[0] = yup2-ty;
3560 xb[1] = x-tx; yb[1] = yup2;
3561 xb[2] = x+tx; yb[2] = yup2;
3562 xb[3] = x+tx; yb[3] = yup2-ty;
3563 gPad->PaintPolyLine(4, xb, yb);
3565 gPad->PaintLine(x-tx,yup2,x+tx,yup2);
3571 ylow2 = gPad->YtoPad(theY[i] - ey);
3572 if (ylow2 < gPad->GetUymin()) ylow2 = gPad->GetUymin();
3573 if (ylow2 < ylow1) {
3575 arrow.PaintArrow(x,ylow1,x,ylow2,asize,arrowOpt);
3577 if (!brackets) gPad->PaintLine(x,ylow1,x,ylow2);
3580 xb[0] = x-tx; yb[0] = ylow2+ty;
3581 xb[1] = x-tx; yb[1] = ylow2;
3582 xb[2] = x+tx; yb[2] = ylow2;
3583 xb[3] = x+tx; yb[3] = ylow2+ty;
3584 gPad->PaintPolyLine(4, xb, yb);
3586 gPad->PaintLine(x-tx,ylow2,x+tx,ylow2);
3592 if (!brackets && !axis) PaintGraphSimple(theGraph, option);
3593 gPad->ResetBit(TGraph::kClipFrame);
3596 Int_t logx = gPad->GetLogx();
3597 Int_t logy = gPad->GetLogy();
3600 if (option4) PaintGraph(theGraph, 2*theNpoints, xline, yline,
"FC");
3601 else PaintGraph(theGraph, 2*theNpoints, xline, yline,
"F");
3602 gPad->SetLogx(logx);
3603 gPad->SetLogy(logy);
3613 void TGraphPainter::PaintGraphPolar(TGraph *theGraph, Option_t* options)
3617 Double_t rwrmin, rwrmax, rwtmin, rwtmax;
3619 TGraphPolar *theGraphPolar = (TGraphPolar*) theGraph;
3621 Int_t theNpoints = theGraphPolar->GetN();
3622 Double_t *theX = theGraphPolar->GetX();
3623 Double_t *theY = theGraphPolar->GetY();
3624 Double_t *theEX = theGraphPolar->GetEX();
3625 Double_t *theEY = theGraphPolar->GetEY();
3627 if (theNpoints<1)
return;
3628 TString opt = options;
3631 Bool_t nolabel = kFALSE;
3632 if (opt.Contains(
"N")){
3634 opt.ReplaceAll(
"N",
"");
3637 TGraphPolargram *thePolargram = theGraphPolar->GetPolargram();
3642 if (thePolargram)
if (!gPad->FindObject(thePolargram->GetName())) thePolargram=0;
3643 if (!thePolargram) {
3645 TListIter padObjIter(gPad->GetListOfPrimitives());
3646 while (TObject* AnyObj = padObjIter.Next()) {
3647 if (TString(AnyObj->ClassName()).CompareTo(
"TGraphPolargram",
3648 TString::kExact)==0)
3649 thePolargram = (TGraphPolargram*)AnyObj;
3650 theGraphPolar->SetPolargram(thePolargram);
3656 if (!thePolargram) {
3658 rwrmin = theY[0]; rwrmax = theY[theNpoints-1];
3659 rwtmin = theX[0]; rwtmax = theX[theNpoints-1];
3661 for (ipt = 0; ipt < theNpoints; ipt++) {
3664 if (theX[ipt] -theEX[ipt] < rwtmin) rwtmin = theX[ipt]-theEX[ipt];
3665 if (theX[ipt] +theEX[ipt] > rwtmax) rwtmax = theX[ipt]+theEX[ipt];
3667 if (theX[ipt] < rwtmin) rwtmin=theX[ipt];
3668 if (theX[ipt] > rwtmax) rwtmax=theX[ipt];
3671 if (theY[ipt] -theEY[ipt] < rwrmin) rwrmin = theY[ipt]-theEY[ipt];
3672 if (theY[ipt] +theEY[ipt] > rwrmax) rwrmax = theY[ipt]+theEY[ipt];
3674 if (theY[ipt] < rwrmin) rwrmin=theY[ipt];
3675 if (theY[ipt] > rwrmax) rwrmax=theY[ipt];
3679 if (rwrmin == rwrmax) rwrmax += 1.;
3680 if (rwtmin == rwtmax) rwtmax += 1.;
3681 Double_t dr = (rwrmax-rwrmin);
3682 Double_t dt = (rwtmax-rwtmin);
3687 rwtmax += dt/theNpoints;
3689 rwrmin = thePolargram->GetRMin();
3690 rwrmax = thePolargram->GetRMax();
3691 rwtmin = thePolargram->GetTMin();
3692 rwtmax = thePolargram->GetTMax();
3695 if ((!thePolargram) || theGraphPolar->GetOptionAxis()) {
3697 thePolargram =
new TGraphPolargram(
"Polargram",rwrmin,rwrmax,rwtmin,rwtmax);
3698 theGraphPolar->SetPolargram(thePolargram);
3699 if (opt.Contains(
"O")) thePolargram->SetBit(TGraphPolargram::kLabelOrtho);
3700 else thePolargram->ResetBit(TGraphPolargram::kLabelOrtho);
3701 if (nolabel) thePolargram->Draw(
"N");
3702 else thePolargram->Draw(
"");
3703 theGraphPolar->SetOptionAxis(kFALSE);
3707 Double_t *theXpol = theGraphPolar->GetXpol();
3708 Double_t *theYpol = theGraphPolar->GetYpol();
3711 Double_t radiusNDC = rwrmax-rwrmin;
3712 Double_t thetaNDC = (rwtmax-rwtmin)/(2*TMath::Pi());
3716 if (opt.Contains(
"E")) {
3718 if (thePolargram->IsDegree()) {c=180/TMath::Pi();}
3719 if (thePolargram->IsGrad()) {c=100/TMath::Pi();}
3721 for (i=0; i<theNpoints; i++) {
3722 Double_t eymin, eymax, exmin,exmax;
3723 exmin = (theY[i]-theEY[i]-rwrmin)/radiusNDC*
3724 TMath::Cos(c*(theX[i]-rwtmin)/thetaNDC);
3725 eymin = (theY[i]-theEY[i]-rwrmin)/radiusNDC*
3726 TMath::Sin(c*(theX[i]-rwtmin)/thetaNDC);
3727 exmax = (theY[i]+theEY[i]-rwrmin)/radiusNDC*
3728 TMath::Cos(c*(theX[i]-rwtmin)/thetaNDC);
3729 eymax = (theY[i]+theEY[i]-rwrmin)/radiusNDC*
3730 TMath::Sin(c*(theX[i]-rwtmin)/thetaNDC);
3731 theGraphPolar->TAttLine::Modify();
3732 if (exmin != exmax || eymin != eymax) gPad->PaintLine(exmin,eymin,exmax,eymax);
3736 for (i=0; i<theNpoints; i++) {
3737 Double_t rad = (theY[i]-rwrmin)/radiusNDC;
3738 Double_t phimin = c*(theX[i]-theEX[i]-rwtmin)/thetaNDC*180/TMath::Pi();
3739 Double_t phimax = c*(theX[i]+theEX[i]-rwtmin)/thetaNDC*180/TMath::Pi();
3740 theGraphPolar->TAttLine::Modify();
3741 if (phimin != phimax) thePolargram->PaintCircle(0,0,rad,phimin,phimax,0);
3747 if (!(gPad->GetLogx()) && !(gPad->GetLogy())) {
3748 Double_t a, b, c=1, x1, x2, y1, y2, discr, norm1, norm2, xts, yts;
3749 Bool_t previouspointin = kFALSE;
3754 if (thePolargram->IsDegree()) {c=180/TMath::Pi();}
3755 if (thePolargram->IsGrad()) {c=100/TMath::Pi();}
3756 for (i=0; i<theNpoints; i++) {
3759 xt = (theY[i]-rwrmin)/radiusNDC*TMath::Cos(c*(theX[i]-rwtmin)/thetaNDC);
3760 yt = (theY[i]-rwrmin)/radiusNDC*TMath::Sin(c*(theX[i]-rwtmin)/thetaNDC);
3761 norm = sqrt(xt*xt+yt*yt);
3766 if (!previouspointin) {
3771 a = (yt-yts)/(xt-xts);
3773 discr = 4*(a*a-b*b+1);
3774 x1 = (-2*a*b+sqrt(discr))/(2*(a*a+1));
3775 x2 = (-2*a*b-sqrt(discr))/(2*(a*a+1));
3778 norm1 = sqrt((x1-xt)*(x1-xt)+(y1-yt)*(y1-yt));
3779 norm2 = sqrt((x2-xt)*(x2-xt)+(y2-yt)*(y2-yt));
3780 previouspointin = kFALSE;
3782 if (norm1 < norm2) {
3792 PaintGraph(theGraphPolar, j+1, theXpol, theYpol, opt);
3797 if (j>=1 && !previouspointin) {
3798 a = (yt-theYpol[j])/(xt-theXpol[j]);
3799 b = theYpol[j]-a*theXpol[j];
3800 previouspointin = kTRUE;
3801 discr = 4*(a*a-b*b+1);
3802 x1 = (-2*a*b+sqrt(discr))/(2*(a*a+1));
3803 x2 = (-2*a*b-sqrt(discr))/(2*(a*a+1));
3806 norm1 = sqrt((x1-xt)*(x1-xt)+(y1-yt)*(y1-yt));
3807 norm2 = sqrt((x2-xt)*(x2-xt)+(y2-yt)*(y2-yt));
3809 if (norm1 < norm2) {
3816 PaintGraph(theGraphPolar, j+1, theXpol, theYpol, opt);
3823 PaintGraph(theGraphPolar, j+1, theXpol, theYpol, opt);
3826 for (i=0; i<theNpoints; i++) {
3827 theXpol[i] = TMath::Abs((theY[i]-rwrmin)/radiusNDC*TMath::Cos((theX[i]-rwtmin)/thetaNDC)+1);
3828 theYpol[i] = TMath::Abs((theY[i]-rwrmin)/radiusNDC*TMath::Sin((theX[i]-rwtmin)/thetaNDC)+1);
3830 PaintGraph(theGraphPolar, theNpoints, theXpol, theYpol,opt);
3835 if (TestBit(TH1::kNoTitle))
return;
3836 Int_t nt = strlen(theGraph->GetTitle());
3837 TPaveText *title = 0;
3839 TIter next(gPad->GetListOfPrimitives());
3840 while ((obj = next())) {
3841 if (!obj->InheritsFrom(TPaveText::Class()))
continue;
3842 title = (TPaveText*)obj;
3843 if (title->GetName())
3844 if (strcmp(title->GetName(),
"title")) {title = 0;
continue;}
3847 if (nt == 0 || gStyle->GetOptTitle() <= 0) {
3848 if (title)
delete title;
3851 Double_t ht = gStyle->GetTitleH();
3852 Double_t wt = gStyle->GetTitleW();
3853 if (ht <= 0) ht = 1.1*gStyle->GetTitleFontSize();
3854 if (ht <= 0) ht = 0.05;
3858 l.SetTitle(theGraph->GetTitle());
3860 ht = TMath::Max(ht, 1.2*l.GetYsize()/(gPad->GetY2() - gPad->GetY1()));
3861 Double_t wndc = l.GetXsize()/(gPad->GetX2() - gPad->GetX1());
3862 wt = TMath::Min(0.7, 0.02+wndc);
3865 TText *t0 = (TText*)title->GetLine(0);
3867 if (!strcmp(t0->GetTitle(),theGraph->GetTitle()))
return;
3868 t0->SetTitle(theGraph->GetTitle());
3869 if (wt > 0) title->SetX2NDC(title->GetX1NDC()+wt);
3874 Int_t talh = gStyle->GetTitleAlign()/10;
3875 if (talh < 1) talh = 1;
else if (talh > 3) talh = 3;
3876 Int_t talv = gStyle->GetTitleAlign()%10;
3877 if (talv < 1) talv = 1;
else if (talv > 3) talv = 3;
3879 Double_t xpos, ypos;
3880 xpos = gStyle->GetTitleX();
3881 ypos = gStyle->GetTitleY();
3883 if (talh == 2) xpos = xpos-wt/2.;
3884 if (talh == 3) xpos = xpos-wt;
3885 if (talv == 2) ypos = ypos+ht/2.;
3886 if (talv == 1) ypos = ypos+ht;
3888 TPaveText *ptitle =
new TPaveText(xpos, ypos-ht, xpos+wt, ypos,
"blNDC");
3891 ptitle->SetFillColor(gStyle->GetTitleFillColor());
3892 ptitle->SetFillStyle(gStyle->GetTitleStyle());
3893 ptitle->SetName(
"title");
3894 ptitle->SetBorderSize(gStyle->GetTitleBorderSize());
3895 ptitle->SetTextColor(gStyle->GetTitleTextColor());
3896 ptitle->SetTextFont(gStyle->GetTitleFont(
""));
3897 if (gStyle->GetTitleFont(
"")%10 > 2)
3898 ptitle->SetTextSize(gStyle->GetTitleFontSize());
3899 ptitle->AddText(theGraph->GetTitle());
3900 ptitle->SetBit(kCanDelete);
3909 void TGraphPainter::PaintGraphQQ(TGraph *theGraph, Option_t *option)
3912 TGraphQQ *theGraphQQ = (TGraphQQ*) theGraph;
3914 Double_t *theX = theGraphQQ->GetX();
3915 Double_t theXq1 = theGraphQQ->GetXq1();
3916 Double_t theXq2 = theGraphQQ->GetXq2();
3917 Double_t theYq1 = theGraphQQ->GetYq1();
3918 Double_t theYq2 = theGraphQQ->GetYq2();
3919 TF1 *theF = theGraphQQ->GetF();
3922 Error(
"TGraphQQ::Paint",
"2nd dataset or theoretical function not specified");
3927 theGraphQQ->GetXaxis()->SetTitle(
"theoretical quantiles");
3928 theGraphQQ->GetYaxis()->SetTitle(
"data quantiles");
3931 PaintGraphSimple(theGraph,option);
3933 Double_t xmin = gPad->GetUxmin();
3934 Double_t xmax = gPad->GetUxmax();
3935 Double_t ymin = gPad->GetUymin();
3936 Double_t ymax = gPad->GetUymax();
3937 Double_t yxmin, xymin, yxmax, xymax;
3938 Double_t xqmin = TMath::Max(xmin, theXq1);
3939 Double_t xqmax = TMath::Min(xmax, theXq2);
3940 Double_t yqmin = TMath::Max(ymin, theYq1);
3941 Double_t yqmax = TMath::Min(ymax, theYq2);
3943 TLine line1, line2, line3;
3944 line1.SetLineStyle(2);
3945 line3.SetLineStyle(2);
3946 yxmin = (theYq2-theYq1)*(xmin-theXq1)/(theXq2-theXq1) + theYq1;
3948 xymin = (theXq2-theXq1)*(ymin-theYq1)/(theYq2-theYq1) + theXq1;
3949 line1.PaintLine(xymin, ymin, xqmin, yqmin);
3952 line1.PaintLine(xmin, yxmin, xqmin, yqmin);
3954 line2.PaintLine(xqmin, yqmin, xqmax, yqmax);
3956 yxmax = (theYq2-theYq1)*(xmax-theXq1)/(theXq2-theXq1) + theYq1;
3958 xymax = (theXq2-theXq1)*(ymax-theYq1)/(theYq2-theYq1) + theXq1;
3959 line3.PaintLine(xqmax, yqmax, xymax, ymax);
3962 line3.PaintLine(xqmax, yqmax, xmax, yxmax);
3969 void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option)
3971 TString opt = option;
3973 TH1F *theHist = (TH1F *)theGraph->GetHistogram();
3975 Bool_t lrx = opt.Contains(
"rx");
3976 Bool_t lry = opt.Contains(
"ry");
3977 Bool_t axis = opt.Contains(
"a");
3978 opt.ReplaceAll(
"a",
"");
3980 Double_t LOX = theHist->GetXaxis()->GetLabelOffset();
3981 Double_t TLX = theHist->GetXaxis()->GetTickLength();
3982 Double_t LOY = theHist->GetYaxis()->GetLabelOffset();
3983 Double_t TLY = theHist->GetYaxis()->GetTickLength();
3984 Int_t XACOL = theHist->GetXaxis()->GetAxisColor();
3985 Int_t YACOL = theHist->GetYaxis()->GetAxisColor();
3989 theHist->GetXaxis()->SetTickLength(0.);
3990 theHist->GetXaxis()->SetLabelOffset(999.);
3991 theHist->GetXaxis()->SetAxisColor(gPad->GetFrameFillColor());
3994 theHist->GetYaxis()->SetTickLength(0.);
3995 theHist->GetYaxis()->SetLabelOffset(999.);
3996 theHist->GetYaxis()->SetAxisColor(gPad->GetFrameFillColor());
3998 theHist->Paint(
"0");
4001 Int_t N = theGraph->GetN();
4002 Double_t *X = theGraph->GetX();
4003 Double_t *Y = theGraph->GetY();
4004 Double_t XA1, XA2, YA1, YA2;
4006 XA1 = theGraph->GetXaxis()->GetXmin();
4007 XA2 = theGraph->GetXaxis()->GetXmax();
4008 YA1 = theGraph->GetYaxis()->GetXmin();
4009 YA2 = theGraph->GetYaxis()->GetXmax();
4011 XA1 = gPad->GetUxmin();
4012 XA2 = gPad->GetUxmax();
4013 YA1 = gPad->GetUymin();
4014 YA2 = gPad->GetUymax();
4016 Double_t dX = XA1+XA2;
4017 Double_t dY = YA1+YA2;
4019 std::vector<Double_t> newX(N);
4020 std::vector<Double_t> newY(N);
4023 opt.ReplaceAll(
"rx",
"");
4026 theHist->GetXaxis()->SetTickLength(0.);
4027 theHist->GetXaxis()->SetLabelOffset(999.);
4031 TString optax =
"-SDH";
4032 if (gPad->GetGridx()) {
4033 GL = (YA2 - YA1) / (gPad->GetY2() - gPad->GetY1());
4036 auto *theNewAxis =
new TGaxis(gPad->GetUxmax(),
4040 theGraph->GetXaxis()->GetXmin(),
4041 theGraph->GetXaxis()->GetXmax(),
4042 theHist->GetNdivisions(
"X"),
4044 theNewAxis->SetLabelFont(theGraph->GetXaxis()->GetLabelFont());
4045 theNewAxis->SetLabelSize(theGraph->GetXaxis()->GetLabelSize());
4046 theNewAxis->SetLabelColor(theGraph->GetXaxis()->GetLabelColor());
4047 theNewAxis->SetTickLength(TLX);
4048 theNewAxis->SetLabelOffset(LOX - theGraph->GetXaxis()->GetLabelSize());
4049 theNewAxis->Paint();
4052 for (Int_t i=0; i<N; i++) newX[i] = dX-X[i];
4054 for (Int_t i=0; i<N; i++) newX[i] = X[i];
4058 opt.ReplaceAll(
"ry",
"");
4063 TString optax =
"-SDH";
4065 if (gPad->GetGridy()) {
4066 GL = (XA2 - XA1) / (gPad->GetX2() - gPad->GetX1());
4069 auto *theNewAxis =
new TGaxis(gPad->GetUxmin(),
4073 theGraph->GetYaxis()->GetXmin(),
4074 theGraph->GetYaxis()->GetXmax(),
4075 theHist->GetNdivisions(
"Y"),
4077 theNewAxis->SetLabelFont(theGraph->GetYaxis()->GetLabelFont());
4078 theNewAxis->SetLabelSize(theGraph->GetYaxis()->GetLabelSize());
4079 theNewAxis->SetLabelColor(theGraph->GetYaxis()->GetLabelColor());
4080 theNewAxis->SetTickLength(-TLY);
4081 theNewAxis->SetLabelOffset(LOY-TLY);
4082 theNewAxis->Paint();
4085 for (Int_t i=0; i<N; i++) newY[i] = dY-Y[i];
4087 for (Int_t i=0; i<N; i++) newY[i] = Y[i];
4091 TGraph *theNewGraph = (TGraph*)theGraph->Clone();
4092 for (Int_t i=0; i<N; i++) theNewGraph->SetPoint(i, newX[i], newY[i]);
4093 theNewGraph->SetMarkerStyle(theGraph->GetMarkerStyle());
4094 theNewGraph->SetMarkerColor(theGraph->GetMarkerColor());
4095 theNewGraph->SetLineStyle(theGraph->GetLineStyle());
4096 theNewGraph->SetLineColor(theGraph->GetLineColor());
4098 PaintHelper(theNewGraph,opt.Data());
4100 theHist->GetXaxis()->SetLabelOffset(LOX);
4101 theHist->GetXaxis()->SetTickLength(TLX);
4102 theHist->GetYaxis()->SetLabelOffset(LOY);
4103 theHist->GetYaxis()->SetTickLength(TLY);
4104 theHist->GetXaxis()->SetAxisColor(XACOL);
4105 theHist->GetYaxis()->SetAxisColor(YACOL);
4112 void TGraphPainter::PaintGraphSimple(TGraph *theGraph, Option_t *option)
4115 if (strstr(option,
"H") || strstr(option,
"h")) {
4116 PaintGrapHist(theGraph, theGraph->GetN(), theGraph->GetX(), theGraph->GetY(), option);
4118 PaintGraph(theGraph, theGraph->GetN(), theGraph->GetX(), theGraph->GetY(), option);
4121 PaintHighlightPoint(theGraph, option);
4125 TList *functions = theGraph->GetListOfFunctions();
4126 if (!functions)
return;
4127 TObjOptLink *lnk = (TObjOptLink*)functions->FirstLink();
4131 obj = lnk->GetObject();
4132 TVirtualPad *padsave = gPad;
4133 if (obj->InheritsFrom(TF1::Class())) {
4134 if (obj->TestBit(TF1::kNotDraw) == 0) obj->Paint(
"lsame");
4136 obj->Paint(lnk->GetOption());
4138 lnk = (TObjOptLink*)lnk->Next();
4152 void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n,
const Double_t *x,
const Double_t *y)
4156 Double_t w = (theGraph->GetLineWidth()/100)*0.005;
4158 Double_t *xf =
new Double_t[2*n];
4159 Double_t *yf =
new Double_t[2*n];
4160 Double_t *xt =
new Double_t[n];
4161 Double_t *yt =
new Double_t[n];
4162 Double_t x1, x2, y1, y2, x3, y3, xm, ym, a, a1, a2, a3;
4165 Int_t ix1,iy1,ix2,iy2;
4166 Int_t iw = gPad->GetWw();
4167 Int_t ih = gPad->GetWh();
4168 Double_t x1p,y1p,x2p,y2p;
4169 gPad->GetPadPar(x1p,y1p,x2p,y2p);
4170 ix1 = (Int_t)(iw*x1p);
4171 iy1 = (Int_t)(ih*y1p);
4172 ix2 = (Int_t)(iw*x2p);
4173 iy2 = (Int_t)(ih*y2p);
4174 Double_t wndc = TMath::Min(1.,(Double_t)iw/(Double_t)ih);
4175 Double_t hndc = TMath::Min(1.,(Double_t)ih/(Double_t)iw);
4176 Double_t rh = hndc/(Double_t)ih;
4177 Double_t rw = wndc/(Double_t)iw;
4178 Double_t x1ndc = (Double_t)ix1*rw;
4179 Double_t y1ndc = (Double_t)iy1*rh;
4180 Double_t x2ndc = (Double_t)ix2*rw;
4181 Double_t y2ndc = (Double_t)iy2*rh;
4184 Double_t rx1,ry1,rx2,ry2;
4185 gPad->GetRange(rx1,ry1,rx2,ry2);
4186 Double_t rx = (x2ndc-x1ndc)/(rx2-rx1);
4187 Double_t ry = (y2ndc-y1ndc)/(ry2-ry1);
4191 xf[0] = rx*(x[0]-rx1)+x1ndc;
4192 yf[0] = ry*(y[0]-ry1)+y1ndc;
4194 for (i=1; i<n; i++) {
4195 if (x[i]==x[i-1] && y[i]==y[i-1])
continue;
4197 xf[nf] = rx*(x[i]-rx1)+x1ndc;
4198 if (xf[i]==xf[i-1]) xf[i] += 0.000001;
4199 yf[nf] = ry*(y[i]-ry1)+y1ndc;
4206 a = TMath::PiOver2();
4208 a = TMath::ATan((yf[1]-yf[0])/(xf[1]-xf[0]));
4211 xt[0] = xf[0]-w*TMath::Sin(a);
4212 yt[0] = yf[0]+w*TMath::Cos(a);
4214 xt[0] = xf[0]+w*TMath::Sin(a);
4215 yt[0] = yf[0]-w*TMath::Cos(a);
4218 if (xf[nf]==xf[nf-1]) {
4219 a = TMath::PiOver2();
4221 a = TMath::ATan((yf[nf]-yf[nf-1])/(xf[nf]-xf[nf-1]));
4223 if (xf[nf]>=xf[nf-1]) {
4224 xt[nf] = xf[nf]-w*TMath::Sin(a);
4225 yt[nf] = yf[nf]+w*TMath::Cos(a);
4227 xt[nf] = xf[nf]+w*TMath::Sin(a);
4228 yt[nf] = yf[nf]-w*TMath::Cos(a);
4231 Double_t xi0,yi0,xi1,yi1,xi2,yi2;
4232 for (i=1; i<nf; i++) {
4240 a1 = TMath::PiOver2();
4242 a1 = TMath::ATan((yi1-yi0)/(xi1-xi0));
4244 if (xi1<xi0) a1 = a1+3.14159;
4246 a2 = TMath::PiOver2();
4248 a2 = TMath::ATan((yi0-yi2)/(xi0-xi2));
4250 if (xi0<xi2) a2 = a2+3.14159;
4251 x1 = xi0-w*TMath::Sin(a1);
4252 y1 = yi0+w*TMath::Cos(a1);
4253 x2 = xi0-w*TMath::Sin(a2);
4254 y2 = yi0+w*TMath::Cos(a2);
4258 a3 = TMath::PiOver2();
4260 a3 = TMath::ATan((ym-yi0)/(xm-xi0));
4262 x3 = xi0-w*TMath::Sin(a3+1.57079);
4263 y3 = yi0+w*TMath::Cos(a3+1.57079);
4265 if ((xm-xi0)*(x3-xi0)<0 && (ym-yi0)*(y3-yi0)<0) {
4269 if ((xm==x1) && (ym==y1)) {
4278 if (xf[nf]==xf[0] && yf[nf]==yf[0]) {
4279 xm = (xt[nf]+xt[0])*0.5;
4280 ym = (yt[nf]+yt[0])*0.5;
4282 a3 = TMath::PiOver2();
4284 a3 = TMath::ATan((ym-yf[0])/(xm-xf[0]));
4286 x3 = xf[0]+w*TMath::Sin(a3+1.57079);
4287 y3 = yf[0]-w*TMath::Cos(a3+1.57079);
4288 if ((xm-xf[0])*(x3-xf[0])<0 && (ym-yf[0])*(y3-yf[0])<0) {
4299 Double_t xc, yc, c1, b1, c2, b2;
4300 Bool_t cross = kFALSE;
4302 for (i=nf2; i>0; i--) {
4303 for (j=i-1; j>0; j--) {
4304 if (xt[i-1]==xt[i] || xt[j-1]==xt[j])
continue;
4305 c1 = (yt[i-1]-yt[i])/(xt[i-1]-xt[i]);
4306 b1 = yt[i]-c1*xt[i];
4307 c2 = (yt[j-1]-yt[j])/(xt[j-1]-xt[j]);
4308 b2 = yt[j]-c2*xt[j];
4310 xc = (b2-b1)/(c1-c2);
4312 if (xc>TMath::Min(xt[i],xt[i-1]) && xc<TMath::Max(xt[i],xt[i-1]) &&
4313 xc>TMath::Min(xt[j],xt[j-1]) && xc<TMath::Max(xt[j],xt[j-1]) &&
4314 yc>TMath::Min(yt[i],yt[i-1]) && yc<TMath::Max(yt[i],yt[i-1]) &&
4315 yc>TMath::Min(yt[j],yt[j-1]) && yc<TMath::Max(yt[j],yt[j-1])) {
4316 nf++; xf[nf] = xt[i]; yf[nf] = yt[i];
4317 nf++; xf[nf] = xc ; yf[nf] = yc;
4335 nf++; xf[nf] = xt[0]; yf[nf] = yt[0];
4338 for (i=0; i<nf+1; i++) {
4339 xf[i] = (1/rx)*(xf[i]-x1ndc)+rx1;
4340 yf[i] = (1/ry)*(yf[i]-y1ndc)+ry1;
4344 gPad->PaintFillArea(nf+1,xf,yf);
4345 theGraph->TAttLine::Modify();
4357 void TGraphPainter::PaintStats(TGraph *theGraph, TF1 *fit)
4361 TPaveStats *stats = 0;
4362 TList *functions = theGraph->GetListOfFunctions();
4363 TIter next(functions);
4365 while ((obj = next())) {
4366 if (obj->InheritsFrom(TPaveStats::Class())) {
4367 stats = (TPaveStats*)obj;
4372 if (stats) dofit = stats->GetOptFit();
4373 else dofit = gStyle->GetOptFit();
4375 if (!dofit) fit = 0;
4377 if (dofit == 1) dofit = 111;
4379 Int_t print_fval = dofit%10;
4380 Int_t print_ferrors = (dofit/10)%10;
4381 Int_t print_fchi2 = (dofit/100)%10;
4382 Int_t print_fprob = (dofit/1000)%10;
4383 Int_t nlinesf = print_fval + print_fchi2 + print_fprob;
4384 if (fit) nlinesf += fit->GetNpar();
4385 Bool_t done = kFALSE;
4386 Double_t statw = 1.8*gStyle->GetStatW();
4387 Double_t stath = 0.25*(nlines+nlinesf)*gStyle->GetStatH();
4392 stats =
new TPaveStats(
4393 gStyle->GetStatX()-statw,
4394 gStyle->GetStatY()-stath,
4396 gStyle->GetStatY(),
"brNDC");
4398 stats->SetParent(functions);
4399 stats->SetOptFit(dofit);
4400 stats->SetOptStat(0);
4401 stats->SetFillColor(gStyle->GetStatColor());
4402 stats->SetFillStyle(gStyle->GetStatStyle());
4403 stats->SetBorderSize(gStyle->GetStatBorderSize());
4404 stats->SetTextFont(gStyle->GetStatFont());
4405 if (gStyle->GetStatFont()%10 > 2)
4406 stats->SetTextSize(gStyle->GetStatFontSize());
4407 stats->SetFitFormat(gStyle->GetFitFormat());
4408 stats->SetStatFormat(gStyle->GetStatFormat());
4409 stats->SetName(
"stats");
4411 stats->SetTextColor(gStyle->GetStatTextColor());
4412 stats->SetTextAlign(12);
4413 stats->SetBit(kCanDelete);
4414 stats->SetBit(kMustCleanup);
4419 Int_t ndf = fit->GetNDF();
4420 snprintf(textstats,50,
"#chi^{2} / ndf = %s%s / %d",
"%",stats->GetFitFormat(),ndf);
4421 snprintf(t,64,textstats,(Float_t)fit->GetChisquare());
4422 if (print_fchi2) stats->AddText(t);
4424 snprintf(textstats,50,
"Prob = %s%s",
"%",stats->GetFitFormat());
4425 snprintf(t,64,textstats,(Float_t)TMath::Prob(fit->GetChisquare(),ndf));
4428 if (print_fval || print_ferrors) {
4429 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
4430 if (print_ferrors) {
4431 snprintf(textstats,50,
"%-8s = %s%s #pm %s%s ",fit->GetParName(ipar),
"%",stats->GetFitFormat(),
"%",stats->GetFitFormat());
4432 snprintf(t,64,textstats,(Float_t)fit->GetParameter(ipar)
4433 ,(Float_t)fit->GetParError(ipar));
4435 snprintf(textstats,50,
"%-8s = %s%s ",fit->GetParName(ipar),
"%",stats->GetFitFormat());
4436 snprintf(t,64,textstats,(Float_t)fit->GetParameter(ipar));
4443 if (!done) functions->Add(stats);
4470 void TGraphPainter::Smooth(TGraph *theGraph, Int_t npoints, Double_t *x, Double_t *y, Int_t drawtype)
4473 Int_t i, k, kp, km, npointsMax, banksize, n2, npt;
4474 Int_t maxiterations, finished;
4475 Int_t jtype, ktype, closed;
4476 Double_t sxmin, sxmax, symin, symax;
4478 Double_t xorg, yorg;
4479 Double_t ratio_signs, xratio, yratio;
4482 Double_t p1, p2, p3, p4, p5, p6;
4483 Double_t w1, w2, w3;
4484 Double_t a, b, c, r, s=0.0, t, z;
4485 Double_t co, so, ct, st, ctu, stu, xnt;
4486 Double_t dx1, dy1, dx2, dy2, dk1, dk2;
4487 Double_t xo, yo, dx, dy, xt, yt;
4488 Double_t xa, xb, ya, yb;
4489 Double_t u1, u2, u3, tj;
4492 Double_t wsign, tsquare, tcube;
4493 c = t = co = so = ct = st = ctu = stu = dx1 = dy1 = dx2 = dy2 = 0;
4494 xt = yt = xa = xb = ya = yb = u1 = u2 = u3 = tj = sb = 0;
4496 npointsMax = npoints*10;
4500 Double_t *qlx =
new Double_t[npointsMax];
4501 Double_t *qly =
new Double_t[npointsMax];
4503 Error(
"Smooth",
"not enough space in memory");
4510 jtype = (drawtype%1000)-10;
4511 if (jtype > 0) { ktype = jtype; loptx = kTRUE; }
4512 else ktype = drawtype%1000;
4514 Double_t ruxmin = gPad->GetUxmin();
4515 Double_t ruymin = gPad->GetUymin();
4520 xorg = TMath::Max((Double_t)0,ruxmin);
4521 yorg = TMath::Min(TMath::Max((Double_t)0,ruymin),gPad->GetUymax());
4541 for (i=1;i<npoints;i++) {
4543 if ((x[i]-x[i-1])*(x[i-1]-x[i-2]) < 0) six++;
4544 if ((y[i]-y[i-1])*(y[i-1]-y[i-2]) < 0) siy++;
4546 if (x[i] < sxmin) sxmin = x[i];
4547 if (x[i] > sxmax) sxmax = x[i];
4548 if (y[i] < symin) symin = y[i];
4549 if (y[i] > symax) symax = y[i];
4552 Double_t dx1n = TMath::Abs(x[npoints-1]-x[0]);
4553 Double_t dy1n = TMath::Abs(y[npoints-1]-y[0]);
4554 if (dx1n < 0.01*(sxmax-sxmin) && dy1n < 0.01*(symax-symin)) closed = 1;
4555 if (sxmin == sxmax) {
4558 if (six > 1) ratio_signs = siy/six;
4559 else ratio_signs = 20;
4560 xratio = ratio_signs/(sxmax-sxmin);
4562 if (symin == symax) yratio = 1;
4563 else yratio = 1/(symax-symin);
4567 for (i=0;i<npoints;i++) {
4568 x[i] = (x[i]-sxmin)*xratio;
4569 y[i] = (y[i]-symin)*yratio;
4588 if (x[0] != x[npoints-1] || y[0] != y[npoints-1])
goto L40;
4589 if (x[npoints-2] == x[npoints-1] && y[npoints-2] == y[npoints-1])
goto L40;
4590 if (x[0] == x[1] && y[0] == y[1])
goto L40;
4613 if (npt > 1)
goto L310;
4617 if (x[k-1] == x[k-2] && y[k-1] == y[k-2])
goto L50;
4622 if (npt > 1)
goto L310;
4625 if (k < npoints)
goto L90;
4626 if (!flgic) { kp = 2;
goto L130;}
4629 if (flgis)
goto L150;
4639 if (x[k-1] == x[k] && y[k-1] == y[k])
goto L80;
4647 if (!flgis)
goto L50;
4662 dx1 = x[k-1] - x[km-1];
4663 dy1 = y[k-1] - y[km-1];
4664 dk1 = dx1*dx1 + dy1*dy1;
4665 dx2 = x[kp-1] - x[k-1];
4666 dy2 = y[kp-1] - y[k-1];
4667 dk2 = dx2*dx2 + dy2*dy2;
4668 ctu = dx1*dk2 + dx2*dk1;
4669 stu = dy1*dk2 + dy2*dk1;
4670 xnt = ctu*ctu + stu*stu;
4682 ct = ctu/TMath::Sqrt(xnt);
4683 st = stu/TMath::Sqrt(xnt);
4684 if (flgis)
goto L160;
4688 w3 = 2*(dx1*dy2-dx2*dy1);
4691 xnt = 1/TMath::Sqrt(co*co+so*so);
4700 w3 = 2*(dx1*dy2-dx2*dy1);
4703 xnt = 1/TMath::Sqrt(ct*ct+st*st);
4709 if (k <= 1)
goto L120;
4736 t = c*6/(TMath::Sqrt(r*r+2*(7-co*ct-so*st)*c)+r);
4739 xa = (a*t-2*dx)/tcube;
4740 xb = (3*dx-(co+a)*t)/tsquare;
4741 ya = (b*t-2*dy)/tcube;
4742 yb = (3*dy-(so+b)*t)/tsquare;
4747 if (.75*TMath::Max(TMath::Abs(dx*so-dy*co),TMath::Abs(dx*st-dy*ct)) <= delta) {
4773 p2 = (u1*tj-u3)*3*tj+u2;
4800 if (w3 > 0) wsign = TMath::Abs(w1);
4801 else wsign = -TMath::Abs(w1);
4802 sth = 0.5+wsign/(3.4*TMath::Abs(w1)+5.2*TMath::Abs(w3));
4803 z = s*sth*(s-s*sth)*(w1*sth+w1+w2);
4804 z = z*z/((a*a+b*b)*(delta*delta));
4805 z = (z+2.642937)*z/((.3715652*z+3.063444)*z+.2441889)-cc;
4809 if (iw > 0)
goto L250;
4810 if (z > err)
goto L240;
4815 if (iw+2 == 0)
goto L190;
4816 if (iw+2 > 0)
goto L290;
4834 theGraph->Zero(kp,0,sb,err,s,z,maxiterations);
4835 if (kp == 2)
goto L210;
4837 Error(
"Smooth",
"Attempt to plot outside plot limits");
4840 if (iw > 0)
goto L200;
4866 qlx[npt] = sxmin + xt/xratio;
4867 qly[npt] = symin + yt/yratio;
4874 if (npt < banksize)
goto L320;
4875 if (drawtype >= 1000 || ktype > 1) {
4876 Int_t newsize = banksize + n2;
4877 Double_t *qtemp =
new Double_t[banksize];
4878 for (i=0;i<banksize;i++) qtemp[i] = qlx[i];
4880 qlx =
new Double_t[newsize];
4881 for (i=0;i<banksize;i++) qlx[i] = qtemp[i];
4882 for (i=0;i<banksize;i++) qtemp[i] = qly[i];
4884 qly =
new Double_t[newsize];
4885 for (i=0;i<banksize;i++) qly[i] = qtemp[i];
4894 if (drawtype >= 1000) {
4895 gPad->PaintFillArea(npt,qlx,qly,
"B");
4899 qlx[npt] = qlx[npt-1];
4900 qlx[npt+1] = qlx[0];
4906 qly[npt] = qly[npt-1];
4907 qly[npt+1] = qly[0];
4909 gPad->PaintFillArea(npt+2,qlx,qly);
4911 if (TMath::Abs(theGraph->GetLineWidth())>99) PaintPolyLineHatches(theGraph, npt, qlx, qly);
4912 gPad->PaintPolyLine(npt,qlx,qly);
4915 qlx[0] = sxmin + xt/xratio;
4916 qly[0] = symin + yt/yratio;
4918 if (finished > 0)
goto L390;
4919 if (finished < 0) { finished = 0;
goto L110;}
4920 if (s > 0)
goto L180;
4926 for (i=0;i<npoints;i++) {
4927 x[i] = sxmin + x[i]/xratio;
4928 y[i] = symin + y[i]/yratio;
4944 void TGraphPainter::SetMaxPointsPerLine(Int_t maxp)
4946 fgMaxPointsPerLine = maxp;
4947 if (maxp < 50) fgMaxPointsPerLine = 50;