code for creating graphs