Set Qt::NoPen to QCPGrid::setPen/setSubGridPen, but not setZeroLinePen.
Qt::NoPen
QCPGrid::setPen
setSubGridPen
setZeroLinePen