update plot code (untested)