@@ -105,8 +105,7 @@ def prepare_data(d, init):
105105 sorted (short2name .items (),
106106 key = lambda short_and_name : short_and_name [1 ]))
107107
108- sorted_labels_and_curves = sorted (labeled_lines , key = cmp_key )
109- for label , line in sorted_labels_and_curves :
108+ for label , line in sorted (labeled_lines , key = cmp_key ):
110109 color = mcolors .to_hex (
111110 mcolors .to_rgba (line .get_color (), line .get_alpha ()),
112111 keep_alpha = True )
@@ -135,16 +134,15 @@ def prepare_data(d, init):
135134 has_curve = bool (curves )
136135
137136 # Get ScalarMappables.
138- mappabledict = []
137+ labeled_mappables = []
139138 for mappable in [* axes .images , * axes .collections ]:
140139 label = mappable .get_label ()
141140 if label == '_nolegend_' or mappable .get_array () is None :
142141 continue
143- mappabledict .append ((label , mappable ))
144- mappablelabels = sorted (mappabledict , key = cmp_key )
142+ labeled_mappables .append ((label , mappable ))
145143 mappables = []
146144 cmaps = [(cmap , name ) for name , cmap in sorted (cm ._cmap_registry .items ())]
147- for label , mappable in mappablelabels :
145+ for label , mappable in sorted ( labeled_mappables , key = cmp_key ) :
148146 cmap = mappable .get_cmap ()
149147 if cmap not in cm ._cmap_registry .values ():
150148 cmaps = [(cmap , cmap .name ), * cmaps ]
@@ -225,7 +223,7 @@ def apply_callback(data):
225223
226224 # Set ScalarMappables.
227225 for index , mappable_settings in enumerate (mappables ):
228- mappable = mappabledict [index ][1 ]
226+ mappable = labeled_mappables [index ][1 ]
229227 if len (mappable_settings ) == 5 :
230228 label , cmap , low , high , interpolation = mappable_settings
231229 mappable .set_interpolation (interpolation )
0 commit comments