hex plotting code