@@ -213,7 +213,9 @@ def open_legend(self, legend, props):
213213 self ._processing_legend = True
214214 self ._legend_visible = props .get ("visible" , True )
215215 if self ._legend_visible :
216- self .msg += " Enabling native plotly legend (matplotlib legend is visible)\n "
216+ self .msg += (
217+ " Enabling native plotly legend (matplotlib legend is visible)\n "
218+ )
217219 self .plotly_fig ["layout" ]["showlegend" ] = True
218220 else :
219221 self .msg += " Not enabling legend (matplotlib legend is not visible)\n "
@@ -229,7 +231,6 @@ def close_legend(self, legend):
229231 self ._legend_visible = False
230232
231233 def draw_bars (self , bars ):
232- 233234 # sort bars according to bar containers
234235 mpl_traces = []
235236 for container in self .bar_containers :
@@ -330,7 +331,7 @@ def draw_bar(self, coll):
330331 ) # TODO ditto
331332 if len (bar ["x" ]) > 1 :
332333 self .msg += " Heck yeah, I drew that bar chart\n "
333- self .plotly_fig .add_trace (bar ),
334+ self .plotly_fig .add_trace (bar )
334335 if bar_gap is not None :
335336 self .plotly_fig ["layout" ]["bargap" ] = bar_gap
336337 else :
@@ -451,13 +452,13 @@ def draw_marked_line(self, **props):
451452 marked_line ["x" ] = mpltools .mpl_dates_to_datestrings (
452453 marked_line ["x" ], formatter
453454 )
454- self .plotly_fig .add_trace (marked_line ),
455+ self .plotly_fig .add_trace (marked_line )
455456 self .msg += " Heck yeah, I drew that line\n "
456457 elif props ["coordinates" ] == "axes" :
457458 # dealing with legend graphical elements
458459 self .msg += " Using native legend\n "
459460 else :
460- self .msg += " Line didn't have 'data' coordinates, " " not drawing\n "
461+ self .msg += " Line didn't have 'data' coordinates, not drawing\n "
461462 warnings .warn (
462463 "Bummer! Plotly can currently only draw Line2D "
463464 "objects from matplotlib that are in 'data' "
@@ -521,7 +522,7 @@ def draw_path_collection(self, **props):
521522 self .msg += " Drawing path collection as markers\n "
522523 self .draw_marked_line (** scatter_props )
523524 else :
524- self .msg += " Path collection not linked to 'data', " " not drawing\n "
525+ self .msg += " Path collection not linked to 'data', not drawing\n "
525526 warnings .warn (
526527 "Dang! That path collection is out of this "
527528 "world. I totally don't know what to do with "
@@ -622,13 +623,17 @@ def draw_text(self, **props):
622623 else : # just a regular text annotation...
623624 self .msg += " Text object is a normal annotation\n "
624625 # Skip creating annotations for legend text when using native legend
625- if self ._processing_legend and self ._legend_visible and props ["coordinates" ] == "axes" :
626- self .msg += " Skipping legend text annotation (using native legend)\n "
627- return
628- if props ["coordinates" ] != "data" :
626+ if (
627+ self ._processing_legend
628+ and self ._legend_visible
629+ and props ["coordinates" ] == "axes"
630+ ):
629631 self .msg += (
630- " Text object isn't linked to 'data' " "coordinates \n "
632+ " Skipping legend text annotation (using native legend) \n "
631633 )
634+ return
635+ if props ["coordinates" ] != "data" :
636+ self .msg += " Text object isn't linked to 'data' coordinates\n "
632637 x_px , y_px = (
633638 props ["mplobj" ].get_transform ().transform (props ["position" ])
634639 )
@@ -638,7 +643,7 @@ def draw_text(self, **props):
638643 xanchor = props ["style" ]["halign" ] # no difference here!
639644 yanchor = mpltools .convert_va (props ["style" ]["valign" ])
640645 else :
641- self .msg += " Text object is linked to 'data' " " coordinates\n "
646+ self .msg += " Text object is linked to 'data' coordinates\n "
642647 x , y = props ["position" ]
643648 axis_ct = self .axis_ct
644649 xaxis = self .plotly_fig ["layout" ]["xaxis{0}" .format (axis_ct )]
@@ -714,9 +719,7 @@ def draw_title(self, **props):
714719 """
715720 self .msg += " Attempting to draw a title\n "
716721 if len (self .mpl_fig .axes ) > 1 :
717- self .msg += (
718- " More than one subplot, adding title as " "annotation\n "
719- )
722+ self .msg += " More than one subplot, adding title as annotation\n "
720723 x_px , y_px = props ["mplobj" ].get_transform ().transform (props ["position" ])
721724 x , y = mpltools .display_to_paper (x_px , y_px , self .plotly_fig ["layout" ])
722725 annotation = go .layout .Annotation (
@@ -734,9 +737,7 @@ def draw_title(self, **props):
734737 )
735738 self .plotly_fig ["layout" ]["annotations" ] += (annotation ,)
736739 else :
737- self .msg += (
738- " Only one subplot found, adding as a " "plotly title\n "
739- )
740+ self .msg += " Only one subplot found, adding as a plotly title\n "
740741 self .plotly_fig ["layout" ]["title" ] = props ["text" ]
741742 title_font = dict (
742743 size = props ["style" ]["fontsize" ], color = props ["style" ]["color" ]
0 commit comments