import pandas as pd import matplotlib.pyplot as plt sample = pd.read_excel(r'...\sample_code.xlsx', sheet_name='sample') print(sample) # read the data from the sample data "replicate of Yang and Preckel's empirical bootstrapped estimates" Income = list(sample['Income']) BP = list(sample['BP']) BL = list(sample['BL']) BU = list(sample['BU']) MP = list(sample['MP']) ML = list(sample['ML']) MU = list(sample['MU']) CP = list(sample['CP']) CL = list(sample['CL']) CU = list(sample['CU']) FP = list(sample['FP']) FL = list(sample['FL']) FU = list(sample['FU']) # Use subplots function and specify the space of graphs (two x two) figure, axis = plt.subplots(2, 2) # Starting from [0, 0]: first row, first column plt.style.use('seaborn') axis[0, 0].scatter(Income, BP, marker="*", s=30, edgecolors="Red", c="Red") axis[0, 0].scatter(Income, BL, marker="X", s=30, edgecolors="Orange", c="Orange") axis[0, 0].scatter(Income, BU, marker="h", s=30, edgecolors="mediumblue", c="mediumblue") axis[0, 0].set_title("Bread and Cereals") # [0, 1]: first row, second column axis[0, 1].scatter(Income, MP, marker="*", s=30, edgecolors="Red", c="Red") axis[0, 1].scatter(Income, ML, marker="X", s=30, edgecolors="Orange", c="Orange") axis[0, 1].scatter(Income, MU, marker="h", s=30, edgecolors="mediumblue", c="mediumblue") axis[0, 1].set_title("Meat, Seafood and Dairy") # [1, 0]: second row, first column axis[1, 0].scatter(Income, CP, marker="*", s=30, edgecolors="Red", c="Red") axis[1, 0].scatter(Income, CL, marker="X", s=30, edgecolors="Orange", c="Orange") axis[1, 0].scatter(Income, CU, marker="h", s=30, edgecolors="mediumblue", c="mediumblue") axis[1, 0].set_title("Calorie-Dense Foods") # [1, 1]: second row, second column axis[1, 1].scatter(Income, FP, marker="*", s=30, edgecolors="Red", c="Red") axis[1, 1].scatter(Income, FL, marker="X", s=30, edgecolors="Orange", c="Orange") axis[1, 1].scatter(Income, FU, marker="h", s=30, edgecolors="mediumblue", c="mediumblue") axis[1, 1].set_title("Fruits and Vegetables") # Remove the tick labels and keep the ones at the bottom axis[0, 0].axes.xaxis.set_ticklabels([]) axis[0, 1].axes.xaxis.set_ticklabels([]) # Set labels on X and Y axes, adjust their positions based on preferences axis[1, 0].set_ylabel('Income Elasticities of Demand', fontweight='bold', fontsize=14, labelpad=15, y=1.11) axis[1, 0].set_xlabel('Per Capita Expenditure in Thousand U.S. Dollars', fontweight='bold', fontsize=14, labelpad=15, x=1.11) # Plot legend, "bbox_to_anchor" may be used to allow manual placement plt.legend(["Point Estimate", "Lower 90%", "Upper 90%"]) plt.show()