0

I need a problem with congestion in Xaxis with DateTime values. Sometimes I need to plot values for just a 10 or 15 seconds interval and it that case everything is ok, but if I have 30 or 40 seconds, X-axis is too crowded.

My code:

def plot_1(data, par_time, par_yticks, par_ylabel, par_legend, par_st, par_et):
    data = data[(data['Time'] >= (par_st - timedelta(seconds=5))) & (data['Time'] <= par_et)]
    fig = plt.figure(figsize=(5.5, 3.5))
    ax1 = fig.add_subplot(111)
    plt.gca().set_color_cycle(['red', 'blue', 'green', 'brown'])
    ax1.plot(data[par_time], data[par_yticks], label=par_ylabel, marker='o', linewidth=2.0)
    plt.ylabel(par_ylabel)
    handles, labels = ax1.get_legend_handles_labels()
    ax1.legend(handles, par_legend, loc='upper center', bbox_to_anchor=(0.8, 1.15))
    ax1.grid('on')
    ax1.set_xlim(par_st, par_et)
    a = plt.savefig("graph.png")
    return a

If there is a need for a data example, I will provide a data samples, immediately.

The output I am getting right now: enter image description here

I have found many questions on StackOverflow with this problem, but nothing works for me. I have used SecondLocater and got the error: Locator attempting to generate 13875840 ticks from 736018.790394 to 737624.790278 exceeds Locator .MAXTICKS So please, don't on the first sight go to mark something as a duplicate, I surely wouldn't waste your time, mine neither.

jovicbg
  • 1,523
  • 8
  • 34
  • 74
  • I think, you need to [angle](https://matplotlib.org/gallery/ticks_and_spines/ticklabels_rotation.html) x-axis labels and select frequency of [x-axis ticks](https://stackoverflow.com/a/19972993/2204131) – ramesh Jun 18 '18 at 19:00
  • I already stated below the last (identical) question that a [mcve] is needed if you want help with an error. – ImportanceOfBeingErnest Jun 18 '18 at 19:38

0 Answers0