Hide axis values but keep axis tick labels in matplotlib

前端 未结 6 1316
星月不相逢
星月不相逢 2021-01-30 06:13

I have this image:

plt.plot(sim_1[\'t\'],sim_1[\'V\'],\'k\')
plt.ylabel(\'V\')
plt.xlabel(\'t\')
plt.show()

I want to hide the numbers

6条回答
  •  悲哀的现实
    2021-01-30 06:45

    Not sure this is the best way, but you can certainly replace the tick labels like this:

    import matplotlib.pyplot as plt
    x = range(10)
    y = range(10)
    plt.plot(x,y)
    plt.xticks(x," ")
    plt.show()
    

    In Python 3.4 this generates a simple line plot with no tick labels on the x-axis. A simple example is here: http://matplotlib.org/examples/ticks_and_spines/ticklabels_demo_rotation.html

    This related question also has some better suggestions: Hiding axis text in matplotlib plots

    I'm new to python. Your mileage may vary in earlier versions. Maybe others can help?

提交回复
热议问题