@@ -213,7 +213,9 @@ def open_legend(self, legend, props):
213
213
self ._processing_legend = True
214
214
self ._legend_visible = props .get ("visible" , True )
215
215
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
+ )
217
219
self .plotly_fig ["layout" ]["showlegend" ] = True
218
220
else :
219
221
self .msg += " Not enabling legend (matplotlib legend is not visible)\n "
@@ -229,7 +231,6 @@ def close_legend(self, legend):
229
231
self ._legend_visible = False
230
232
231
233
def draw_bars (self , bars ):
232
-
233
234
# sort bars according to bar containers
234
235
mpl_traces = []
235
236
for container in self .bar_containers :
@@ -330,7 +331,7 @@ def draw_bar(self, coll):
330
331
) # TODO ditto
331
332
if len (bar ["x" ]) > 1 :
332
333
self .msg += " Heck yeah, I drew that bar chart\n "
333
- self .plotly_fig .add_trace (bar ),
334
+ self .plotly_fig .add_trace (bar )
334
335
if bar_gap is not None :
335
336
self .plotly_fig ["layout" ]["bargap" ] = bar_gap
336
337
else :
@@ -451,13 +452,13 @@ def draw_marked_line(self, **props):
451
452
marked_line ["x" ] = mpltools .mpl_dates_to_datestrings (
452
453
marked_line ["x" ], formatter
453
454
)
454
- self .plotly_fig .add_trace (marked_line ),
455
+ self .plotly_fig .add_trace (marked_line )
455
456
self .msg += " Heck yeah, I drew that line\n "
456
457
elif props ["coordinates" ] == "axes" :
457
458
# dealing with legend graphical elements
458
459
self .msg += " Using native legend\n "
459
460
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 "
461
462
warnings .warn (
462
463
"Bummer! Plotly can currently only draw Line2D "
463
464
"objects from matplotlib that are in 'data' "
@@ -521,7 +522,7 @@ def draw_path_collection(self, **props):
521
522
self .msg += " Drawing path collection as markers\n "
522
523
self .draw_marked_line (** scatter_props )
523
524
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 "
525
526
warnings .warn (
526
527
"Dang! That path collection is out of this "
527
528
"world. I totally don't know what to do with "
@@ -622,13 +623,17 @@ def draw_text(self, **props):
622
623
else : # just a regular text annotation...
623
624
self .msg += " Text object is a normal annotation\n "
624
625
# 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
+ ):
629
631
self .msg += (
630
- " Text object isn't linked to 'data' " "coordinates \n "
632
+ " Skipping legend text annotation (using native legend) \n "
631
633
)
634
+ return
635
+ if props ["coordinates" ] != "data" :
636
+ self .msg += " Text object isn't linked to 'data' coordinates\n "
632
637
x_px , y_px = (
633
638
props ["mplobj" ].get_transform ().transform (props ["position" ])
634
639
)
@@ -638,7 +643,7 @@ def draw_text(self, **props):
638
643
xanchor = props ["style" ]["halign" ] # no difference here!
639
644
yanchor = mpltools .convert_va (props ["style" ]["valign" ])
640
645
else :
641
- self .msg += " Text object is linked to 'data' " " coordinates\n "
646
+ self .msg += " Text object is linked to 'data' coordinates\n "
642
647
x , y = props ["position" ]
643
648
axis_ct = self .axis_ct
644
649
xaxis = self .plotly_fig ["layout" ]["xaxis{0}" .format (axis_ct )]
@@ -714,9 +719,7 @@ def draw_title(self, **props):
714
719
"""
715
720
self .msg += " Attempting to draw a title\n "
716
721
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 "
720
723
x_px , y_px = props ["mplobj" ].get_transform ().transform (props ["position" ])
721
724
x , y = mpltools .display_to_paper (x_px , y_px , self .plotly_fig ["layout" ])
722
725
annotation = go .layout .Annotation (
@@ -734,9 +737,7 @@ def draw_title(self, **props):
734
737
)
735
738
self .plotly_fig ["layout" ]["annotations" ] += (annotation ,)
736
739
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 "
740
741
self .plotly_fig ["layout" ]["title" ] = props ["text" ]
741
742
title_font = dict (
742
743
size = props ["style" ]["fontsize" ], color = props ["style" ]["color" ]
0 commit comments