Graph Only X Axis Matplotlib

0

I want to graph only X axis in Matplotlib.

I have a list x = [0,1,2,3,4,5,6] and I want to draw only the x axis with that range of values. I do not need a vertical axis, only the horizontal axis. As an example, I add an image.

I hope someone can help me.

    
asked by fcuturrufo 16.05.2018 в 23:04
source

1 answer

0

To hide an axis you can use the method matplotlib.axes.Axes.set_visible If you also want to eliminate the lines that delimit the data area you can use matplotlib.spines.Spine.set_visible() :

import numpy as np
import matplotlib.pyplot as plt



ax = plt.subplot(111)


ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.gca().axes.get_yaxis().set_visible(False)
ax.set_yticklabels(())
ax.set_xlim([-5, 25])
ax.set_xticks(range(0, 25, 5))

ax.set_xlabel('Latitude')

plt.show()

    
answered by 17.05.2018 / 02:13
source