diff --git a/experiment/meteo_france_data/scm_models_data/abstract_study.py b/experiment/meteo_france_data/scm_models_data/abstract_study.py index ff8ffbbc4d1c66e745e5997a0247ba542dd99e82..54dd606d5df1e994f366d03f8f1f2afce1dc0fdf 100644 --- a/experiment/meteo_france_data/scm_models_data/abstract_study.py +++ b/experiment/meteo_france_data/scm_models_data/abstract_study.py @@ -231,6 +231,8 @@ class AbstractStudy(object): default_color_for_missing_massif='w', default_color_for_nan_values='w', massif_name_to_color=None, + show_label=True, + scaled=False, ): if ax is None: ax = plt.gca() @@ -244,7 +246,7 @@ class AbstractStudy(object): create_colorbase_axis(ax, label, cmap, norm) m = cm.ScalarMappable(norm=norm, cmap=cmap) colors = [m.to_rgba(value) if not np.isnan(value) else default_color_for_nan_values for value in values] - massif_name_to_color = zip(massif_names, colors) + massif_name_to_color = dict(zip(massif_names, colors)) massif_name_to_fill_kwargs = {massif_name: {'color': color} for massif_name, color in massif_name_to_color.items()} massif_names = list(massif_name_to_fill_kwargs.keys()) @@ -280,11 +282,17 @@ class AbstractStudy(object): ax.scatter(masssif_coordinate_for_display.x_coordinates, masssif_coordinate_for_display.y_coordinates, s=1) - # Improve some explanation on the X axis and on the Y axis - ax.set_xlabel('Longitude (km)') - ax.xaxis.set_major_formatter(get_km_formatter()) - ax.set_ylabel('Latitude (km)') - ax.yaxis.set_major_formatter(get_km_formatter()) + if show_label: + # Improve some explanation on the X axis and on the Y axis + ax.set_xlabel('Longitude (km)') + ax.xaxis.set_major_formatter(get_km_formatter()) + ax.set_ylabel('Latitude (km)') + ax.yaxis.set_major_formatter(get_km_formatter()) + else: + # Remove the ticks + ax.get_xaxis().set_visible(False) + ax.get_yaxis().set_visible(False) + # Display the name or value of the massif if add_text: for _, row in masssif_coordinate_for_display.df_all_coordinates.iterrows(): @@ -293,6 +301,9 @@ class AbstractStudy(object): value = massif_name_to_value[massif_name] ax.text(x, y, str(round(value, 1))) + if scaled: + plt.axis('scaled') + if show: plt.show() diff --git a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py index cce373b30cdd55ed5eb0492516f85acb1585caa0..825fc91b2a2443f1b4ecce0829236781e345fcec 100644 --- a/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py +++ b/experiment/meteo_france_data/scm_models_data/visualization/study_visualization/study_visualizer.py @@ -590,14 +590,16 @@ class StudyVisualizer(VisualizationParameters): # Display the graph of the max on top ax = plt.gca() x, y = self.smooth_maxima_x_y(massif_names.index(massif_name)) - ax.plot(x, y, color=color) - ax.set_ylabel('{} (in {})'.format(snow_abbreviation, self.study.variable_unit), color=color) + ax.plot(x, y, color=color, linewidth=5) + ax.set_ylabel('{} (in {})'.format(snow_abbreviation, self.study.variable_unit), color=color, fontsize=15) ax.xaxis.set_ticks(x[2::10]) + ax.tick_params(axis='both', which='major', labelsize=13) + # self.visualize_massif_graphs(self.visualize_mean_and_max_graph, # specified_massif_ids=specified_massif_ids) plot_name = 'Annual maxima of {} in {} at {}m'.format(snow_abbreviation, massif_name, altitude) self.plot_name = plot_name - self.show_or_save_to_file(add_classic_title=False) + self.show_or_save_to_file(add_classic_title=False, no_title=True) ax.clear() def visualize_mean_and_max_graph(self, ax, massif_id): @@ -733,7 +735,7 @@ class StudyVisualizer(VisualizationParameters): label_function(full_title) ax0.tick_params(axis=u'both', which=u'both', length=0) - def show_or_save_to_file(self, add_classic_title=True): + def show_or_save_to_file(self, add_classic_title=True, no_title=False): assert self.plot_name is not None if add_classic_title: title = self.study.title @@ -742,7 +744,7 @@ class StudyVisualizer(VisualizationParameters): title = self.plot_name if self.only_one_graph: plt.suptitle(self.plot_name) - else: + elif not no_title: plt.suptitle(title) if self.show: plt.show()