Skip to content

Commit 64d5be9

Browse files
Run ruff format
1 parent 1528322 commit 64d5be9

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

plotly/matplotlylib/renderer.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -329,7 +331,7 @@ def draw_bar(self, coll):
329331
) # TODO ditto
330332
if len(bar["x"]) > 1:
331333
self.msg += " Heck yeah, I drew that bar chart\n"
332-
(self.plotly_fig.add_trace(bar),)
334+
self.plotly_fig.add_trace(bar)
333335
if bar_gap is not None:
334336
self.plotly_fig["layout"]["bargap"] = bar_gap
335337
else:
@@ -450,7 +452,7 @@ def draw_marked_line(self, **props):
450452
marked_line["x"] = mpltools.mpl_dates_to_datestrings(
451453
marked_line["x"], formatter
452454
)
453-
(self.plotly_fig.add_trace(marked_line),)
455+
self.plotly_fig.add_trace(marked_line)
454456
self.msg += " Heck yeah, I drew that line\n"
455457
elif props["coordinates"] == "axes":
456458
# dealing with legend graphical elements
@@ -621,8 +623,14 @@ def draw_text(self, **props):
621623
else: # just a regular text annotation...
622624
self.msg += " Text object is a normal annotation\n"
623625
# Skip creating annotations for legend text when using native legend
624-
if self._processing_legend and self._legend_visible and props["coordinates"] == "axes":
625-
self.msg += " Skipping legend text annotation (using native legend)\n"
626+
if (
627+
self._processing_legend
628+
and self._legend_visible
629+
and props["coordinates"] == "axes"
630+
):
631+
self.msg += (
632+
" Skipping legend text annotation (using native legend)\n"
633+
)
626634
return
627635
if props["coordinates"] != "data":
628636
self.msg += " Text object isn't linked to 'data' coordinates\n"

plotly/matplotlylib/tests/test_renderer.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def test_legend_disabled_when_no_matplotlib_legend():
4444

4545
# Should not have showlegend explicitly set to True
4646
# (Plotly's default behavior when no legend elements exist)
47-
assert not hasattr(plotly_fig.layout, 'showlegend') or plotly_fig.layout.showlegend != True
47+
assert (
48+
not hasattr(plotly_fig.layout, "showlegend")
49+
or plotly_fig.layout.showlegend != True
50+
)
4851

4952

5053
def test_legend_disabled_when_matplotlib_legend_not_visible():
@@ -57,15 +60,18 @@ def test_legend_disabled_when_matplotlib_legend_not_visible():
5760
plotly_fig = tls.mpl_to_plotly(fig)
5861

5962
# Should not enable legend when matplotlib legend is hidden
60-
assert not hasattr(plotly_fig.layout, 'showlegend') or plotly_fig.layout.showlegend != True
63+
assert (
64+
not hasattr(plotly_fig.layout, "showlegend")
65+
or plotly_fig.layout.showlegend != True
66+
)
6167

6268

6369
def test_multiple_traces_native_legend():
6470
"""Test native legend works with multiple traces of different types."""
6571
fig, ax = plt.subplots()
66-
ax.plot([0, 1, 2], [0, 1, 0], '-', label="Line")
67-
ax.plot([0, 1, 2], [1, 0, 1], 'o', label="Markers")
68-
ax.plot([0, 1, 2], [0.5, 0.5, 0.5], 's-', label="Line+Markers")
72+
ax.plot([0, 1, 2], [0, 1, 0], "-", label="Line")
73+
ax.plot([0, 1, 2], [1, 0, 1], "o", label="Markers")
74+
ax.plot([0, 1, 2], [0.5, 0.5, 0.5], "s-", label="Line+Markers")
6975
ax.legend()
7076

7177
plotly_fig = tls.mpl_to_plotly(fig)

0 commit comments

Comments
 (0)