Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Set axis linecolor to black by default when converting from matplotli…
…b figure
  • Loading branch information
robertoffmoura committed Oct 9, 2025
commit 08b9e443ad29cd67fcf0c9b066400087158e4e8e
4 changes: 2 additions & 2 deletions plotly/matplotlylib/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def open_axes(self, ax, props):
self.axis_ct += 1
# set defaults in axes
xaxis = go.layout.XAxis(
anchor="y{0}".format(self.axis_ct), zeroline=False, ticks="inside"
anchor="y{0}".format(self.axis_ct), zeroline=False, ticks="inside", linecolor="black"
)
yaxis = go.layout.YAxis(
anchor="x{0}".format(self.axis_ct), zeroline=False, ticks="inside"
anchor="x{0}".format(self.axis_ct), zeroline=False, ticks="inside", linecolor="black"
)
# update defaults with things set in mpl
mpl_xaxis, mpl_yaxis = mpltools.prep_xy_axis(
Expand Down
10 changes: 10 additions & 0 deletions plotly/matplotlylib/tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ def test_multiple_traces_native_legend():
assert plotly_fig.data[0].mode == "lines"
assert plotly_fig.data[1].mode == "markers"
assert plotly_fig.data[2].mode == "lines+markers"


def test_axis_linecolor_defaults_to_black():
fig, ax = plt.subplots()
ax.plot([0, 1], [0, 1])

plotly_fig = tls.mpl_to_plotly(fig)

assert plotly_fig.layout.xaxis.linecolor == "black"
assert plotly_fig.layout.yaxis.linecolor == "black"