Skip to content

Commit

Permalink
change axis labels for ratio plots to english
Browse files Browse the repository at this point in the history
  • Loading branch information
kdemmich committed Jan 30, 2024
1 parent 10d2918 commit cd4fc2b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
9 changes: 4 additions & 5 deletions WeatherRoutingTool/routeparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion WeatherRoutingTool/utils/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 33 additions & 17 deletions compare_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,38 @@ 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')


if __name__ == "__main__":
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"

Expand All @@ -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
Expand Down

0 comments on commit cd4fc2b

Please sign in to comment.