Bug 3098 - mettre à jour les graphiques montrant l'évolution du cluster
- improved readability by ordering owners; as a result, owners of the same lab are no longer separated
This commit is contained in:
parent
faf6cd5d2a
commit
08ac2506ae
|
@ -137,7 +137,14 @@ def stackplot(ax, x_signal, y_signals, legend_location='best'):
|
|||
else:
|
||||
# emulating missing Axes.stackplot method
|
||||
colors = get_rgb_palette(num_colors=len(y_signals), saturation=1.0, value=0.8) # ['blue', 'orange', 'green', 'purple', 'yellow', 'cyan']
|
||||
y = np.row_stack(list(y_signals.itervalues()))
|
||||
|
||||
# we sort the signals according to their labels to group departments of the same lab together on the plot
|
||||
ordered_y_signals = []
|
||||
ordered_labels = []
|
||||
for label, y_signal in sorted(y_signals.items()):
|
||||
ordered_y_signals.append(y_signal)
|
||||
ordered_labels.append(label)
|
||||
y = np.row_stack(ordered_y_signals)
|
||||
# this call to 'cumsum' (cumulative sum), passing in your y data,
|
||||
# is necessary to avoid having to manually order the datasets
|
||||
y_stack = np.cumsum(y, axis=0) # a 3x10 array
|
||||
|
@ -151,9 +158,9 @@ def stackplot(ax, x_signal, y_signals, legend_location='best'):
|
|||
ax.add_patch(p)
|
||||
|
||||
if legend_location == 'outside right':
|
||||
plt.legend(list(y_signals.keys()), bbox_to_anchor=(1.10, 1.00), loc='upper left') # force the legend into the bounding box
|
||||
plt.legend(ordered_labels, bbox_to_anchor=(1.10, 1.00), loc='upper left') # force the legend into the bounding box
|
||||
else:
|
||||
plt.legend(list(y_signals.keys()), loc=legend_location)
|
||||
plt.legend(ordered_labels, loc=legend_location)
|
||||
|
||||
|
||||
def draw_cluster_value_over_time_graph(inventory, from_date, to_date, graph_type):
|
||||
|
@ -223,7 +230,6 @@ def draw_cluster_value_over_time_graph(inventory, from_date, to_date, graph_type
|
|||
ax.xaxis.set_major_formatter(yearsFmt)
|
||||
ax.xaxis.set_minor_locator(months)
|
||||
|
||||
|
||||
# rotates and right aligns the x labels, and moves the bottom of the
|
||||
# axes up to make room for them
|
||||
# fig.autofmt_xdate()
|
||||
|
|
Loading…
Reference in New Issue