Removing axis ticks in Python Matplotlib plots while keeping the axes labels

You can remove the axes in a Matplotlib plot with the command axis('off') but if you want to keep the axes labels, that doesn't work. So, here is a way around it:

ax = subplot(1,1,1) 
ax.plot(somedata) 
ax.set_xticks([]) 
ax.set_yticks([]) 
xlabel('some label for x') 
ylabel('some label for y')

You can customize your axis ticks and tick labels using set_xticks(), set_yticks(), set_xticklabels() and set_yticklabels(). Check the Maplotlib documentation for more details.

Comments

  1. Hey, appreciated the post. Google showed it then I had to follow the link.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular Posts