user1602492
user1602492

Reputation:

Getting rid of frame and axis labels

I have done some research, but every solution I found didn't work for what comes with 'Anaconda-2.2.0-Linux-x86_64.sh'... Can someone tell me how to get rid of the frame and the axis labels?

boros = GeoDataFrame.from_file('nybb/nybb.shp') 
boros.plot()

enter image description here

Upvotes: 0

Views: 115

Answers (1)

Primer
Primer

Reputation: 10302

Here is a way to remove spines and tick labels:

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

x = np.linspace(-np.pi, np.pi, 100)
y = 2*np.sin(x)

ax.plot(x, y) 

ax.patch.set_visible(False)
ax.grid('off')

[ax.spines[spine].set_visible(False) for spine in ax.spines]

ax.set_xticklabels([]);
ax.set_yticklabels([]);

plt.show()

enter image description here

Note that when you call .plot() you need to pass a reference to axes object where the plot will be placed, like so .plot(ax=ax).

If you do not have a variable referring to the axes object you could access current axes with plt.gca().

Upvotes: 1

Related Questions