Skip to content Skip to sidebar Skip to footer

Matplotlib Axis Tick Labels Covered By Scatterplot (using Spines)

I want to have my axis through the origin (0,0) in a scatter plot, which is why I have set the spines positions in the below example. The problem is that my actual data points on t

Solution 1:

You can fix this by setting the zorder of scatter to something <0

For example:

plt.scatter(x,y,zorder=-5)

Unfortunately, even then they are not very visible in the ggplot style:

enter image description here

You can see that more clearly if you change the color of the scatter plot and the labels (note that the labels are clearly above the scatter plot in the image below), so you may need to experiment to find something you like

ax.tick_params(labelcolor='r')
plt.scatter(x,y,color='w',zorder=-5)

enter image description here

Solution 2:

Another option is to add

ax.set_axisbelow(False)

after you do plt.scatter(), and the output is

axis zorder

Post a Comment for "Matplotlib Axis Tick Labels Covered By Scatterplot (using Spines)"