code to construct plot4