@@ -167,29 +167,41 @@ def _parse_annotation_coords(ff, coords, xy):
167167def _get_arrow_style (obj , data ):
168168 # get a style string from a FancyArrowPatch
169169 arrow_translate = {
170- ArrowStyle ._style_list ["-" ]: ["-" ],
171- ArrowStyle ._style_list ["->" ]: ["->" ],
172- ArrowStyle ._style_list ["<-" ]: ["<-" ],
173- ArrowStyle ._style_list ["<->" ]: ["<->" ],
174- ArrowStyle ._style_list ["|-|" ]: ["|-|" ],
175- ArrowStyle ._style_list ["-|>" ]: ["-latex" ],
176- ArrowStyle ._style_list ["<|-" ]: ["latex-" ],
177- ArrowStyle ._style_list ["<|-|>" ]: ["latex-latex" ],
178- ArrowStyle ._style_list ["]-[" ]: ["|-|" ],
179- ArrowStyle ._style_list ["-[" ]: ["-|" ],
180- ArrowStyle ._style_list ["]-" ]: ["|-" ],
181- ArrowStyle ._style_list ["fancy" ]: ["-latex" , "very thick" ],
182- ArrowStyle ._style_list ["simple" ]: ["-latex" , "very thick" ],
183- ArrowStyle ._style_list ["wedge" ]: ["-latex" , "very thick" ],
170+ "-" : ["-" ],
171+ "->" : ["->" ],
172+ "<-" : ["<-" ],
173+ "<->" : ["<->" ],
174+ "<|-" : ["latex-" ],
175+ "-|>" : ["-latex" ],
176+ "<|-|>" : ["latex-latex" ],
177+ "]-" : ["|-" ],
178+ "-[" : ["-|" ],
179+ "]-[" : ["|-|" ],
180+ "|-|" : ["|-|" ],
181+ "]->" : ["]->" ],
182+ "<-[" : ["<-[" ],
183+ "simple" : ["-latex" , "very thick" ],
184+ "fancy" : ["-latex" , "very thick" ],
185+ "wedge" : ["-latex" , "very thick" ],
184186 }
185187 style_cls = type (obj .get_arrowstyle ())
186- try :
187- style = arrow_translate [style_cls ]
188- except KeyError :
188+
189+ # Sometimes, mpl adds new arrow styles to the ArrowStyle._style_list dictionary.
190+ # To support multiple mpl versions, check in a loop instead of a dictionary lookup.
191+ latex_style = None
192+ for key , value in arrow_translate .items ():
193+ if key not in ArrowStyle ._style_list :
194+ continue
195+
196+ if ArrowStyle ._style_list [key ] == style_cls :
197+ latex_style = value
198+ break
199+
200+ if latex_style is None :
189201 raise NotImplementedError (f"Unknown arrow style { style_cls } " )
190- else :
191- data , col , _ = _color .mpl_color2xcolor (data , obj .get_ec ())
192- return style + ["draw=" + col ]
202+
203+ data , col , _ = _color .mpl_color2xcolor (data , obj .get_ec ())
204+ return latex_style + ["draw=" + col ]
193205
194206
195207def _annotation (obj , data , content ):
0 commit comments