Borderless matplotlib plots

matplotlib, python

Solution

A similar question was asked here: How can I remove the top and right axis in matplotlib?. A Google search for "hide axes matplotlib" gives that as the 5th link.

Remove the spines:

x = linspace(0, 2 * pi, 1000)
y = sin(x)
fig, ax = subplots()
ax.plot(x, y)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.grid(axis='y')

Problem

Is there a way to save matplotlib graphs without the border around the frame while keeping the background not transparent? Setting the frame to 'off' as I show in the code below does not work as this removes the background making it transparent whereas I want to retain the white background, just without the borders. ``` a = fig.gca() a.set_frame_on(False) ``` Here is a screenshot of what I'm trying to do. If the border can be removed then I can draw the x-axis line separately. All suggestions are much appreciated.

Original source

Related problems