8

Is there a way to remove the x/y axis numbers(values) from a plot? I still want to keep the frame and grid in the plot though. /Jonas

2
  • possible dublicate of stackoverflow.com/questions/2176424/… Commented Nov 8, 2013 at 13:01
  • Yes thanks, however is there a way to still have a grid in the plot? Commented Nov 8, 2013 at 13:02

2 Answers 2

7

depending on how you have created the plot... the simplest way would be to set the xaxis tick to an empty list

from matplotlib import pylab

x = [1,2,3,4,5]
y = [2,4,6,8,10]

pylab.plot(x,y)
frame = pylab.gca()

frame.axes.get_xaxis().set_ticks([])
frame.axes.get_yaxis().set_ticks([])

pylab.show()
Sign up to request clarification or add additional context in comments.

3 Comments

Yes thanks, however is there a way to still have a grid in the plot?
set_ticklabels([]) instead of set_ticks([])
It would be better to use NullLocator and NullForamatter
0

Use ax[i].set_axis_off() if you are using subplots.

https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_axis_off.html

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.