0

plotting a graph but manully changing xticks labels

   plt.plot(range(df.shape[0]), (df['Low'] + df['High']) / 2.0)
    plt.xticks( range(0,df.shape[0],500),df['Date'].loc[::500], rotation=45)
    plt.xlabel('Date', fontsize=18)
    plt.ylabel('Mid Price', fontsize=18)
    plt.title(label="Year wise data", fontsize=40,
          color="green")
    # print("shape",df.shape[0])
    # print(range(0, df.shape[0], 500))
    print( df['Date'].loc[500:])
    # print(range(10000, df.shape[0],500), df['Date'].loc[::500])
    # print(range(10000,df.shape[0],500))
    plt.show()

this part of code will plot a graph which consists of data from the year 1962 to 2014(14,000 lines)

something like this

enter image description here

but i just want to change the xticks to show the values from 13,000 line to the last one but when i tried to change the range

 range(13000,df.shape[0],500) 

which is supposed to get values from 13000 to 14000 with 500 interval but instead im getting error

The number of FixedLocator locations (3), usually from a call to set_ticks, does not match the number of ticklabels (29).

or something similar if i change the values

i have tried to change location or value through here but it is of no use

df['Date'].loc[::500]

is there anyway where we can manually add xticks irrespective of the data at that location

  • 1
    Does this answer your question? [The number of FixedLocator locations (11), usually from a call to set\_ticks, does not match the number of ticklabels (166) | Matplotlib](https://stackoverflow.com/questions/69242965/the-number-of-fixedlocator-locations-11-usually-from-a-call-to-set-ticks-doe) – Alfabravo Jun 02 '22 at 19:57

0 Answers0