added R 3D plotting and improved 2D plotting