plotting function and plot