Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Hiding axes values in Matplotlib

I want to hide the x,y axes values as highlighted in the figure. Is it possible to do it? I also attach the expected representation.

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

n=3 
X = np.arange(n)
Y = -X

x_sorted = np.sort(X)
y_sorted = np.sort(Y)

ax.set_xticks(x_sorted)
ax.set_yticks(y_sorted)

ax.set_xlim(x_sorted[0], x_sorted[-1])
ax.set_ylim(y_sorted[0], y_sorted[-1])

ax.grid()
ax.set_aspect('equal', 'box')
plt.show()

enter image description here

The expected representation is

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

You need to empty x and y tick labels from ax variable:

ax.set_yticklabels([])
ax.set_xticklabels([])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading