Python Matplotlib scatter plot adding x-axis labels -


i have following code in order generate scatterplots

            import matplotlib.pyplot plt                line = plt.figure()                   plt.plot(xvalue, yvalue)               plt.grid(true)               plt.savefig("test.png")               plt.show() 

and here screenshot of plot: enter image description here

i wondering if change x-axis labels strings. have stored labels in

    xlabel = ['2015/4/1', '2015/4/11', '2015/4/12', '2015/4/18', '2015/4/19'...] 

is there function matplotlib set x-axis labels values in "xlabel"?

many thx!

also labels overlapped, fix problem? thx!

enter image description here

here answer. target plot datetime xticklabel.
this. code this:

## example, have 9 daily value during 2013-04-01 2014-04-10 start = datetime.datetime.strptime("01-04-2013", "%d-%m-%y") end = datetime.datetime.strptime("10-04-2013", "%d-%m-%y") date = [start + datetime.timedelta(days=x) x in range(0, (end-start).days)]  plt.figure(figsize=(12,4)) ## y data want plot ind = np.arange(len(y)) ax=plt.subplot() plt.plot(ind,y,lw = 3) k = [] in range(0,len(ind),1):     k.append(str(date[i])[0:10])  plt.xticks(ind,k,rotation=65) 

enter image description here

update

to solve overlap problem, recommend code below:

for label in ax.xaxis.get_ticklabels()[::2]:     label.set_visible(false)        

for daily value in month, can figure this:

enter image description here


Comments

Popular posts from this blog

github - Git errors while pushing -

c++ - How can I delete a QSharedPointer -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -