I use scatter()
to produce this plot:
Then I convert the plot to a numpy array for further processing and get this:
How can I get rid of the border?
Here is my code:
import matplotlib.pyplot as plt
import numpy as np
n = 500
domain_size = 1000
x = np.random.randint(0,domain_size,(n,2))
fig, ax = plt.subplots(frameon=False)
fig.set_size_inches((5,5))
ax.scatter(x[:,0], x[:,1], c="black", s=200, marker="*")
ax.set_xlim(0,domain_size)
ax.set_ylim(0,domain_size)
fig.add_axes(ax)
fig.canvas.draw()
X = np.array(fig.canvas.renderer._renderer)
X = 0.2989*X[:,:,1] + 0.5870*X[:,:,2] + 0.1140*X[:,:,3]
plt.show()
plt.close()
plt.imshow(X, interpolation="none", cmap="gray")
plt.show()
imshow
plot...fig.set_size_inches(())
. Settingxlim
orylim
has no effects onX
and therefore does not solve my problem. Any other suggestion?