1

I am plotting a sample pandas dataframe, but I am not able to remove interpolated xticks, that the plot() function automatically generates, but are not relevant to me.

I would like to keep xticks labels only for those dates where I have actual data to show (they are the dates where the lines show the dot marker: 05-13-00, 05-14-00,05-15-00, 05-16-00, 05-17-00 and so on).

I would need some solution which works even if I am changing the dates by refreshing the input data with new dates.

I tried several options, including using `set xticks`` in seaborn but did not succeed in removing those extra auto generated xticks labels.

dp = ds.rename(columns={0: "count", 1: "market", 2: "date"})
dp.set_index('date', inplace=True)
dp.groupby('market')['count'].plot(legend=True, marker='o')
plt.xticks(rotation = 45)
None

plot result

vestland
  • 55,229
  • 37
  • 187
  • 305
  • 2
    Did you try `plt.xticks(df.index.unique())` to set the x-ticks to be the unique dates i.e. those that have corresponding points to plot? – Mustafa Aydın May 17 '21 at 17:48

0 Answers0