def plot(cls_num): os.chdir(os.path.join(wltpdb.mydir, wltpdb.samples_dir)) cls_name = class_name_from_num(cls_num) data = data_meanN_gears(cls_num) cols = data.keys() assert len(cols) == 4, cols parts = zip(model.get_class_part_names(), [ dict(data_fmt='1', data_kws=dict(color='#0000ff', markersize=4.8, ), diff_kws=dict(linestyle=':', linewidth=4) ), dict(data_fmt='_', data_kws=dict(color='#0033cc', markersize=4.8, fillstyle='none'), diff_kws=dict(linestyle='-.',linewidth=4) ), dict(data_fmt='o', data_kws=dict(color='#006699', markersize=4.8, fillstyle='none'), diff_kws=dict(linestyle='-',linewidth=4) ), dict(data_fmt='+', data_kws=dict(color='#009966', markersize=4.8, fillstyle='none'), diff_kws=dict(linestyle='--', linewidth=4) ), ]) axes_tuple = None for (part, kws) in parts: try: ## veh part N/gear/Py/Heinz X = data.loc[(slice(None), part), cols[0]] Y = data.loc[(slice(None), part), cols[1]] X_REF = data.loc[(slice(None), part), cols[2]] Y_REF = data.loc[(slice(None), part), cols[3]] except KeyError: continue axes_tuple, artist_tuple = plots.plot_xy_diffs_arrows( X, Y, X_REF, Y_REF, data_label='Python, %s'%part, diff_label='Diffs %s'%part, diff_cmap=cm.cool, #@UndefinedVariable title="%s: Python(arrow-heads) compared to AccessDb-2secAccel (arrow-tails)" % cls_name, x_label=r'Mean Gear', y_label='$Mean EngineSpeed [rpm]$', axes_tuple=axes_tuple, **kws ) axes_tuple[0].legend(loc=1, fancybox=True, framealpha=0.5) axes_tuple[1].legend(loc=2, fancybox=True, framealpha=0.5) return data, axes_tuple
from wltp.test import wltp_db_tests as wltpdb def prepare_data(gened_column, heinz_column): gened_column='rpm' heinz_column='n' vehdata = wltpdb.aggregate_single_columns_means(gened_column, heinz_column) vehdata['pmr'] = 1000.0 * vehdata['rated_power'] / vehdata['kerb_mass'] return vehdata.pmr, vehdata.gened, vehdata.heinz if __name__ == '__main__': os.chdir(os.path.join(wltpdb.mydir, wltpdb.samples_dir)) (X, Y, Y_REF) = prepare_data(gened_column='rpm', heinz_column='n') kws = dict(data_fmt='ok', data_kws=dict(markersize=4.5, fillstyle='none'), ) plots.plot_xy_diffs_arrows( X, Y, X, Y_REF, title="Python(arrow-heads) vs AccessDb-2secAccel (arrow-tails)", x_label=r'$PMR [W/kg]$', y_label='EngineSpeed [rpm]', ref_label='Access-db', data_label='Python', mark_sections='classes', **kws ) plt.show()
def prepare_data(gened_column, heinz_column): gened_column = "rpm" heinz_column = "n" vehdata = wltpdb.aggregate_single_columns_means(gened_column, heinz_column) vehdata["pmr"] = 1000.0 * vehdata["rated_power"] / vehdata["kerb_mass"] return vehdata.pmr, vehdata.gened, vehdata.heinz if __name__ == "__main__": os.chdir(os.path.join(wltpdb.mydir, wltpdb.samples_dir)) (X, Y, Y_REF) = prepare_data(gened_column="rpm", heinz_column="n") kws = dict(data_fmt="ok", data_kws=dict(markersize=4.5, fillstyle="none")) plots.plot_xy_diffs_arrows( X, Y, X, Y_REF, title="Python(arrow-heads) vs AccessDb-2secAccel (arrow-tails)", x_label=r"$PMR [W/kg]$", y_label="EngineSpeed [rpm]", ref_label="Access-db", data_label="Python", mark_sections="classes", **kws) plt.show()