diff --git a/histpainter/src/THistPainter.cxx b/histpainter/src/THistPainter.cxx
index 70dc581b38a90a8da7ab724629adaf88815a731d..c6e6f3f8e4d2b9657841f62a750a140e1ad61e75 100644
--- a/histpainter/src/THistPainter.cxx
+++ b/histpainter/src/THistPainter.cxx
@@ -1,4 +1,4 @@
-// @(#)root/histpainter:$Name:  $:$Id: THistPainter.cxx,v 1.278 2006/12/12 13:41:38 couet Exp $
+// @(#)root/histpainter:$Name:  $:$Id: THistPainter.cxx,v 1.279 2007/01/03 14:24:58 brun Exp $
 // Author: Rene Brun   26/08/99
 
 /*************************************************************************
@@ -1672,6 +1672,7 @@ void THistPainter::PaintArrows(Option_t *)
    fH->SetLineWidth(1);
    fH->TAttLine::Modify();
 
+   Double_t xk, xstep, yk, ystep;
    Double_t dx, dy, si, co, anr, x1, x2, y1, y2, xc, yc, dxn, dyn;
    Int_t   ncx  = Hparam.xlast - Hparam.xfirst + 1;
    Int_t   ncy  = Hparam.ylast - Hparam.yfirst + 1;
@@ -1685,7 +1686,12 @@ void THistPainter::PaintArrows(Option_t *)
 
    for (Int_t id=1;id<=2;id++) {
       for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
+         yk    = fYaxis->GetBinLowEdge(j);
+         ystep = fYaxis->GetBinWidth(j);
          for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
+            xk    = fXaxis->GetBinLowEdge(i);
+            xstep = fXaxis->GetBinWidth(i);
+            if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
             if (i == Hparam.xfirst) {
                dx = fH->GetCellContent(i+1, j) - fH->GetCellContent(i, j);
             } else if (i == Hparam.xlast) {
@@ -3242,6 +3248,7 @@ void THistPainter::Paint2DErrors(Option_t *)
       xyerror = gStyle->GetErrorX();
    }
 
+   Double_t xk, xstep, yk, ystep;
    for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
       y  = fYaxis->GetBinCenter(j);
       ey = fYaxis->GetBinWidth(j)*xyerror;
@@ -3255,7 +3262,12 @@ void THistPainter::Paint2DErrors(Option_t *)
          if (y2 > 0) y2 = TMath::Log10(y2);
          else        y2 = Hparam.ymin;
       }
+      yk    = fYaxis->GetBinLowEdge(j);
+      ystep = fYaxis->GetBinWidth(j);
       for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
+         xk    = fXaxis->GetBinLowEdge(i);
+         xstep = fXaxis->GetBinWidth(i);
+         if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
          Int_t bin = fH->GetBin(i,j);
          x  = fXaxis->GetBinCenter(i);
          ex = fXaxis->GetBinWidth(i)*xyerror;