From cd4fc2bd5d01d8a6176baad8510478b26692c35a Mon Sep 17 00:00:00 2001 From: Katharina Demmich Date: Tue, 30 Jan 2024 12:07:30 +0100 Subject: [PATCH] change axis labels for ratio plots to english --- WeatherRoutingTool/routeparams.py | 9 +++-- WeatherRoutingTool/utils/graphics.py | 2 +- compare_routes.py | 50 ++++++++++++++++++---------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/WeatherRoutingTool/routeparams.py b/WeatherRoutingTool/routeparams.py index 332800a..bd26c03 100644 --- a/WeatherRoutingTool/routeparams.py +++ b/WeatherRoutingTool/routeparams.py @@ -279,9 +279,9 @@ def plot_route(self, ax, colour, label): def get_power_type(self, power_type): if power_type == 'power': - return {"value": self.ship_params_per_step.get_power(), "label": 'Leistung', "unit": u.Watt} + return {"value": self.ship_params_per_step.get_power(), "label": 'power consumption', "unit": u.Watt} if power_type == 'fuel': - return {"value": self.get_fuel_per_dist(), "label": "Treibstoffverbrauch", "unit": u.kg} + return {"value": self.get_fuel_per_dist(), "label": "fuel consumption", "unit": u.kg} def plot_power_vs_dist(self, color, label, power_type, ax): power = self.get_power_type(power_type) @@ -392,10 +392,9 @@ def plot_power_vs_dist_ratios(self, denominator, color, label, power_type): plt.errorbar(x=hist_values_nom["bin_centres"].to(u.km).value, y=hist_values_ratios, yerr=None, xerr=hist_values_nom["bin_widths"].to(u.km).value/2, fmt=' ', color=color, linestyle=None) plt.axhline(y=mean_dev, color=color, linestyle='dashed') - plt.axhline(y=1, color='gainsboro', linestyle='-') - plt.xlabel('Weglänge (km)') - plt.ylabel(power_nom["label"] + ' Modifiziert/Standardwert') + plt.xlabel('travel distance (km)') + plt.ylabel(power_nom["label"] + ' modified/standard') plt.xticks() def plot_power_vs_coord(self, ax, color, label, coordstring, power_type): diff --git a/WeatherRoutingTool/utils/graphics.py b/WeatherRoutingTool/utils/graphics.py index b3b4e27..3c04b17 100644 --- a/WeatherRoutingTool/utils/graphics.py +++ b/WeatherRoutingTool/utils/graphics.py @@ -140,7 +140,7 @@ def plot_legend(fig): def get_colour(i): - colours = ['darkred', 'mediumblue', 'olive', 'peachpuff', 'seagreen', 'gold', 'darkviolet', 'crimson', + colours = ['darkred', 'mediumblue', 'seagreen', 'darkviolet', 'olive', 'peachpuff', 'gold', 'crimson', 'moccasin', 'plum', 'firebrick', 'skyblue'] if (i > 10): i = i-10 diff --git a/compare_routes.py b/compare_routes.py index 6b692fe..ee927a5 100644 --- a/compare_routes.py +++ b/compare_routes.py @@ -44,21 +44,27 @@ def plot_power_vs_coord(rp_list, rp_str_list, coordstring, power_type='fuel'): def plot_power_vs_dist_ratios(rp_list, rp_str_list, scenario_str, power_type='fuel'): - # windspeed = '12.5' - fig, ax = plt.subplots(figsize=(12, 8), dpi=96) - ax.set_ylim(0.8, 1.2) + ax.set_ylim(0.95, 1.08) + colour = 0 for irp in range(1, len(rp_list)): - rp_list[irp].plot_power_vs_dist_ratios(rp_list[0], graphics.get_colour(irp), - rp_str_list[irp], power_type) - - ax.legend(loc='upper left', frameon=False) + if rp_str_list[irp] == '': + rp_list[irp].plot_power_vs_dist_ratios(rp_list[0], graphics.get_colour(colour), + rp_str_list[irp], power_type) + colour = colour + 1 + else: + rp_list[irp].plot_power_vs_dist_ratios(rp_list[0], graphics.get_colour(colour), + rp_str_list[irp], power_type) + + ax.legend(loc='upper left', bbox_to_anchor=(0, 1), handlelength=0.1, frameon=False) ax.tick_params(top=True, right=True) - ax.text(0.95, 0.96, scenario_str, verticalalignment='top', horizontalalignment='right', + ax.text(0.98, 0.96, scenario_str, verticalalignment='top', horizontalalignment='right', transform=ax.transAxes) - ax.text(0.11, 0.825, 'gestrichelte Linien: Mittelwerte', verticalalignment='top', horizontalalignment='left', + + ax.text(0.11, 0.76, 'dashed lines: averages', verticalalignment='top', horizontalalignment='left', transform=ax.transAxes) + # plt.axhline(y=1, color='gainsboro', linestyle='-') plt.savefig(figurefile + '/' + power_type + '_vs_dist_ratios' + '.png') @@ -66,7 +72,10 @@ def plot_power_vs_dist_ratios(rp_list, rp_str_list, scenario_str, power_type='fu filename1 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_original.json") filename2 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_95perc_calm.json") filename3 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_105perc_calm.json") - filename4 = ("/home/kdemmich/MariData/Code/Data/RouteCollection/min_time_route.json") + filename4 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_80perc_wind.json") + filename5 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_120perc_wind.json") + filename6 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_80perc_wave.json") + filename7 = ("/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Routes/route_real_weather_120perc_wave.json") figurefile = "/home/kdemmich/MariData/IMDC_paper/Routes_24_01_24/Figures" @@ -79,19 +88,26 @@ def plot_power_vs_dist_ratios(rp_list, rp_str_list, scenario_str, power_type='fu rp_read1 = RouteParams.from_file(filename1) rp_read2 = RouteParams.from_file(filename2) rp_read3 = RouteParams.from_file(filename3) + rp_read4 = RouteParams.from_file(filename4) + rp_read5 = RouteParams.from_file(filename5) + rp_read6 = RouteParams.from_file(filename6) + rp_read7 = RouteParams.from_file(filename7) - # rp_read3 = RouteParams.from_file(filename3) +# rp_read3 = RouteParams.from_file(filename3) # rp_read4 = RouteParams.from_file(filename4) rp_1_str = 'Originalroute' - rp_2_str = '95% Glattwasserwiderstand' - rp_3_str = '105% Glattwasserwiderstand' - rp_4_str = 'original' + rp_2_str = r'$\pm5\,\%$ calm water resistance' + rp_3_str = '' + rp_4_str = r'$\pm20\,\%$ added resistance in wind' + rp_5_str = '' + rp_6_str = r'$\pm20\,\%$ added resistance in waves' + rp_7_str = '' - scenario_str = 'Mittelmeer-Szenario' + scenario_str = 'scenario: Mediterranean Sea' - rp_list = [rp_read1, rp_read2, rp_read3] - rp_str_list = [rp_1_str, rp_2_str, rp_3_str] + rp_list = [rp_read1, rp_read2, rp_read3, rp_read4, rp_read5, rp_read6, rp_read7] + rp_str_list = [rp_1_str, rp_2_str, rp_3_str, rp_4_str, rp_5_str, rp_6_str, rp_7_str] do_plot_weather = False do_plot_route = True