code and plot