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

Someone marked this question as a duplicate, but when I used code from the answer in that "duplicate" question, I got an errors like this: Locator attempting to generate 13875840 ticks from 736018.790394 to 737624.790278 exceeds Locator .MAXTICKS I that was a helpful answer I will use it, of course, not wasting my time.

jovicbg
  • 1,523
  • 8
  • 34
  • 74
  • @ImportanceOfBeingErnest I have added something to my question, please read... I wouldn't ask a question if I found something helpful on StackOverflow. – jovicbg Jun 18 '18 at 14:55
  • Questions without a [mcve] are a waste of time. Hence this was closed. If you want to show *in how far* the linked solution does not work with a runnable example code, this question can be reopened and someone will sure be happy to answer it. – ImportanceOfBeingErnest Jun 18 '18 at 16:45

0 Answers0