0

I'm plotting a scatter plot with a grid. The code is as follows:

x0=4554440
y0=526375

fig, ax=plt.subplots()

ax.grid(True, linewidth=0.5, linestyle='--', which='major', color='grey')
ax.grid(True, linewidth=0.5, linestyle='--', which='major', color='grey')
ax.set_xticks(range(4554440, 4554440+9550, 382))
ax.set_yticks(range(526375, 526375+9550, 382))
              
ax.scatter(*zip(*serv_points), s=3)

ax.set_xlim(4554440, 4554440+9550)
ax.set_ylim(526375, 526375+9550)

ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)

plt.show()

And this is the output:

enter image description here

But I want to hide the axis values. I have already searched on how to this, using:

ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)

Or this

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

But the output is this:

enter image description here

And I want to keep the grid. Does anyone know to do this?

Thanks!

Beatriz Santos
  • 117
  • 3
  • 11
  • `ax.set_yticklabels([])`, `ax.set_xticklabels([])`, `for tic in ax.xaxis.get_major_ticks():` `tic.tick1line.set_visible(False)` `for tic in ax.yaxis.get_major_ticks():` `tic.tick1line.set_visible(False)` – BigBen Apr 07 '23 at 13:55

0 Answers0