src/ei_mcoe/ei_mcoe.py
def plot_prep(df, fields_to_plot, xy_limits, scale="linear"):
    """Make plots to compare FERC & EIA reported values for Coal & Gas plants.

    For each of the fields specified in fields_to_plot, create a pair of plots,
    one for 'gas' and one for 'coal' in the same frame, showing the EIA
    quantity vs. the FERC quantity in a scatter plot.

    Args:
        df (pandas.DataFrame): A DataFrame with merged FERC and EIA data
            (the product of the compare_ferc_eia() function).
        fields_to_plot (list): A list of columns to be compared FERC v. EIA.
        xy_limits (dict): A dictionary depicting the plot limits for each
            field_to_plot.
        scale (str): A string defining the plot scale (linear or log)
    """
    for field in fields_to_plot:
        field_eia = field + '_eia'
        field_ferc1 = field + '_ferc1'
        x_coal = df.query("primary_fuel_by_mmbtu=='coal'")[field_eia]
        y_coal = df.query("primary_fuel_by_mmbtu=='coal'")[field_ferc1]
        x_gas = df.query("primary_fuel_by_mmbtu=='gas'")[field_eia]
        y_gas = df.query("primary_fuel_by_mmbtu=='gas'")[field_ferc1]
        fig, (coal_ax, gas_ax) = plt.subplots(
            ncols=2, nrows=1, figsize=(17, 8))

        slope, intercept, r_value, p_value, std_err = stats.linregress(x_coal,
                                                                       y_coal)
        coal_ax.scatter(x_coal, y_coal, color='black', alpha=0.1, label=field)
        coal_ax.set_xlim(xy_limits[field][0], xy_limits[field][1])
        coal_ax.set_ylim(xy_limits[field][0], xy_limits[field][1])
        coal_ax.set_xlabel('EIA')
        coal_ax.set_yscale(scale)
        coal_ax.set_xscale(scale)
        coal_ax.set_ylabel('FERC Form 1')
        coal_ax.set_title((f"{field} (Coal),\
                            r-squared = {(r_value**2).round(3)}"))

        slope, intercept, r_value, p_value, std_err = stats.linregress(x_gas,
                                                                       y_gas)
        gas_ax.scatter(x_gas, y_gas, color='blue', alpha=0.1, label=field)
        gas_ax.set_xlim(xy_limits[field][0], xy_limits[field][1])
        gas_ax.set_ylim(xy_limits[field][0], xy_limits[field][1])
        gas_ax.set_yscale(scale)
        gas_ax.set_xscale(scale)
        gas_ax.set_xlabel('EIA')
        gas_ax.set_ylabel('FERC Form 1')
        gas_ax.set_title((f"{field} (Gas), \
                          r-squared = {(r_value**2).round(3)}"))

        plt.tight_layout()
        plt.savefig(f"{field}_ferc1_vs_eia.png")
Make plots to compare FERC & EIA reported values for Coal & Gas plants.

    For each of the fields specified in fields_to_plot, create a pair of plots,
    one for 'gas' and one for 'coal' in the same frame, showing the EIA
    quantity vs. the FERC quantity in a scatter plot.

    Args:
        df (pandas.DataFrame): A DataFrame with merged FERC and EIA data
            (the product of the compare_ferc_eia() function).
        fields_to_plot (list): A list of columns to be compared FERC v. EIA.
        xy_limits (dict): A dictionary depicting the plot limits for each
            field_to_plot.
        scale (str): A string defining the plot scale (linear or log)
    
Make plots to compare FERC & EIA reported values for Coal & Gas plants.
For each of the fields specified in fields_to_plot, create a pair of plots,
one for 'gas' and one for 'coal' in the same frame, showing the EIA
quantity vs. the FERC quantity in a scatter plot.
Make plots to compare FERC & EIA reported values for Coal & Gas plants . For each of the fields specified in fields_to_plot create a pair of plots one for ' gas ' and one for ' coal ' in the same frame showing the EIA quantity vs . the FERC quantity in a scatter plot .
def plot_prep(df, fields_to_plot, xy_limits, scale="linear"):
    for field in fields_to_plot:
        field_eia = field + '_eia'
        field_ferc1 = field + '_ferc1'
        x_coal = df.query("primary_fuel_by_mmbtu=='coal'")[field_eia]
        y_coal = df.query("primary_fuel_by_mmbtu=='coal'")[field_ferc1]
        x_gas = df.query("primary_fuel_by_mmbtu=='gas'")[field_eia]
        y_gas = df.query("primary_fuel_by_mmbtu=='gas'")[field_ferc1]
        fig, (coal_ax, gas_ax) = plt.subplots(
            ncols=2, nrows=1, figsize=(17, 8))
        slope, intercept, r_value, p_value, std_err = stats.linregress(x_coal,
                                                                       y_coal)
        coal_ax.scatter(x_coal, y_coal, color='black', alpha=0.1, label=field)
        coal_ax.set_xlim(xy_limits[field][0], xy_limits[field][1])
        coal_ax.set_ylim(xy_limits[field][0], xy_limits[field][1])
        coal_ax.set_xlabel('EIA')
        coal_ax.set_yscale(scale)
        coal_ax.set_xscale(scale)
        coal_ax.set_ylabel('FERC Form 1')
        coal_ax.set_title((f"{field} (Coal),\
                            r-squared = {(r_value**2).round(3)}"))
        slope, intercept, r_value, p_value, std_err = stats.linregress(x_gas,
                                                                       y_gas)
        gas_ax.scatter(x_gas, y_gas, color='blue', alpha=0.1, label=field)
        gas_ax.set_xlim(xy_limits[field][0], xy_limits[field][1])
        gas_ax.set_ylim(xy_limits[field][0], xy_limits[field][1])
        gas_ax.set_yscale(scale)
        gas_ax.set_xscale(scale)
        gas_ax.set_xlabel('EIA')
        gas_ax.set_ylabel('FERC Form 1')
        gas_ax.set_title((f"{field} (Gas), \
                          r-squared = {(r_value**2).round(3)}"))
        plt.tight_layout()
        plt.savefig(f"{field}_ferc1_vs_eia.png")
def plot_prep ( df , fields_to_plot , xy_limits , scale = "linear" ) : for field in fields_to_plot : field_eia = field + '_eia' field_ferc1 = field + '_ferc1' x_coal = df . query ( "primary_fuel_by_mmbtu=='coal'" ) [ field_eia ] y_coal = df . query ( "primary_fuel_by_mmbtu=='coal'" ) [ field_ferc1 ] x_gas = df . query ( "primary_fuel_by_mmbtu=='gas'" ) [ field_eia ] y_gas = df . query ( "primary_fuel_by_mmbtu=='gas'" ) [ field_ferc1 ] fig , ( coal_ax , gas_ax ) = plt . subplots ( ncols = 2 , nrows = 1 , figsize = ( 17 , 8 ) ) slope , intercept , r_value , p_value , std_err = stats . linregress ( x_coal , y_coal ) coal_ax . scatter ( x_coal , y_coal , color = 'black' , alpha = 0.1 , label = field ) coal_ax . set_xlim ( xy_limits [ field ] [ 0 ] , xy_limits [ field ] [ 1 ] ) coal_ax . set_ylim ( xy_limits [ field ] [ 0 ] , xy_limits [ field ] [ 1 ] ) coal_ax . set_xlabel ( 'EIA' ) coal_ax . set_yscale ( scale ) coal_ax . set_xscale ( scale ) coal_ax . set_ylabel ( 'FERC Form 1' ) coal_ax . set_title ( ( f"{field} (Coal),\
                            r-squared = {(r_value**2).round(3)}" ) ) slope , intercept , r_value , p_value , std_err = stats . linregress ( x_gas , y_gas ) gas_ax . scatter ( x_gas , y_gas , color = 'blue' , alpha = 0.1 , label = field ) gas_ax . set_xlim ( xy_limits [ field ] [ 0 ] , xy_limits [ field ] [ 1 ] ) gas_ax . set_ylim ( xy_limits [ field ] [ 0 ] , xy_limits [ field ] [ 1 ] ) gas_ax . set_yscale ( scale ) gas_ax . set_xscale ( scale ) gas_ax . set_xlabel ( 'EIA' ) gas_ax . set_ylabel ( 'FERC Form 1' ) gas_ax . set_title ( ( f"{field} (Gas), \
                          r-squared = {(r_value**2).round(3)}" ) ) plt . tight_layout ( ) plt . savefig ( f"{field}_ferc1_vs_eia.png" )
Make plots to compare FERC & EIA reported values for Coal & Gas plants.
Make plots to compare FERC & EIA reported values for Coal & Gas plants .
"""Make plots to compare FERC & EIA reported values for Coal & Gas plants.

    For each of the fields specified in fields_to_plot, create a pair of plots,
    one for 'gas' and one for 'coal' in the same frame, showing the EIA
    quantity vs. the FERC quantity in a scatter plot.

    Args:
        df (pandas.DataFrame): A DataFrame with merged FERC and EIA data
            (the product of the compare_ferc_eia() function).
        fields_to_plot (list): A list of columns to be compared FERC v. EIA.
        xy_limits (dict): A dictionary depicting the plot limits for each
            field_to_plot.
        scale (str): A string defining the plot scale (linear or log)
    """
df
A DataFrame with merged FERC and EIA data
(the product of the compare_ferc_eia() function).
A DataFrame with merged FERC and EIA data ( the product of the compare_ferc_eia () function ) .
fields_to_plot
A list of columns to be compared FERC v. EIA.
A list of columns to be compared FERC v . EIA .
xy_limits
A dictionary depicting the plot limits for each
field_to_plot.
A dictionary depicting the plot limits for each field_to_plot .
scale
A string defining the plot scale (linear or log)
A string defining the plot scale ( linear or log )