updated ng plotting code