Commit 80879176 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[POSTER] improve max plot for poster. improve abstract study visualization function.

parent d6c951d2
No related merge requests found
Showing with 24 additions and 11 deletions
+24 -11
......@@ -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()
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment