add plotting in c++ inplementation