why does my matplotlib graph look quantized on the x-axis?

Viewed 58

I have a graph with prices rendered with QT5Agg. It is interactive, where we can zoom in, etc.

When looking at it from close, it is horrible:

enter image description here

While, when zoomed out, it looks good.

Focusing on the top part, here is the code:

# subplot 1 - price
ax1.plot(df['timestamp'], df['price'], color='midnightblue', alpha=0.6, zorder=0)
ax1.plot(df['timestamp'], df['order_long_price'], color='lightgreen', alpha=0.6, zorder=1)
ax1.plot(df['timestamp'], df['order_short_price'], color='orangered', alpha=0.6, zorder=1)
ax1.plot(df['timestamp'], df['break_even_long'], color='limegreen', linewidth=2, zorder=2)
ax1.plot(df['timestamp'], df['break_even_short'], color='crimson', linewidth=2, zorder=2)
ax1.plot(df['timestamp'], df['break_even_hedge'], color='fuchsia', linewidth=2, zorder=2)
ax1.set_ylabel('price USDT')
ax1.margins(x=0)

The timestamp is highly irregular, it matches actual market trades and some areas are dense, some are sparse. I have roughly 1M values, spanning 7 days.

It looks like the x positions are somehow quantized because there are vertical lines and they seem to happen at regular intervals. I understand that two values happening at a short interval would look like a vertical line, but the x axis data seems quite block-ish for something which has a ms precision.

Why could that be?

0 Answers
Related