modified plot_graph