# How to make 3d z out of range plane disappear

Hi:
I need to use TF2 to draw a surface, and some part of the surface approaches infinite. So I use SetMaximum to control the z range. However, The out of range part still appears as a plane right at the SetMaximum value. So I want to ask how the make such plane disappear.

Here is my c++ code:

[code]#include<TCanvas.h>
#include<TF2.h>
#include
#include
#include

constexpr double EquilibriumDistance{1.40112};
constexpr double Mass{1837.2893*2/3};
constexpr double WidthControl{1.0288158995136472};
constexpr double WellDepth{0.174454};
constexpr double Transformation12{-1/std::sqrt(3)},Transformation22{2/std::sqrt(3)};
constexpr double Overlap{0.1475};

constexpr double morse(double const Distance)
{
return WellDepth*(std::exp(-2WidthControl(Distance-EquilibriumDistance))-2std::exp(-WidthControl(Distance-EquilibriumDistance)));
}

constexpr double antimorse(double const Distance)
{
return WellDepth/2*(std::exp(-2WidthControl(Distance-EquilibriumDistance))+2std::exp(-WidthControl(Distance-EquilibriumDistance)));
}

constexpr double coulomb(double const Distance)
{
return ((1+Overlap)::morse(Distance)+(1-Overlap)::antimorse(Distance))/2;
}

constexpr double exchange(double const Distance)
{
return ((1+Overlap)::morse(Distance)-(1-Overlap)::antimorse(Distance))/2;
}

auto drainageDivideToXY(double const DrainageDivide,double const Perpendicular)
{
return std::array<double,2>{(std::sqrt(3)*DrainageDivide-Perpendicular)/2,(DrainageDivide+std::sqrt(3)*Perpendicular)/2};
}

inline double potential(std::function<decltype(::drainageDivideToXY)>::result_type const XY)
{
double const AB{XY.front()+XY.back()*Transformation12},BC{XY.back()*Transformation22},CA{AB+BC};
return (::coulomb(AB)+::coulomb(BC)+::coulomb(CA)-std::sqrt((std::pow(::exchange(AB)-::exchange(BC),2)+std::pow(::exchange(BC)-::exchange(CA),2)+std::pow(::exchange(CA)-::exchange(AB),2))/2))/(1+Overlap);
}

int main()
{
TCanvas canvas;
TF2 potential(“potential”,[](auto constVariable,auto const){return ::potential(std::array<double,2>{Variable,Variable});},0,8,0,8);
potential.SetNpx(40);
potential.SetNpy(40);
potential.SetMaximum(0);
potential.Draw(“surf”);
canvas.SetTheta(45);
canvas.SetPhi(230);
canvas.Print(“original.pdf”);
}[/code]

and I use g++ -std=c++1y -O2 to compile the source code, and the plot is orginal.pdf (49.8 KB)

Now I want to make the grid right at z=0 disappear, just like the desire.pdf (79.7 KB). You can ignore other difference between such two pdf.

you can do that only with LEGo plot. See:
root.cern.ch/root/html534/THistPainter.html#HP17 (Option 0)