Matplotlib fill_between behaving incorrectly

Viewed 44

I'm using maptplotlib to plot points. I want to fill area between two points from x-axis. the two pints in x-axis are p1 = 1643237118161 and p2 = 1643237119999. When I try to plot the graph, the fill area is a very thin line, but if I increase the p2 point by just 1 to 1643237120000, the fill area is bigger and can be seen better. My question is why if I use p2 = 1643237119999, I get a very thin line? How can this be fixed?

# Code for plot
fig, ax = plt.subplots()
ax.plot(df_gpsprobe.timestamp, df_gpsprobe.speed, 'ro-')
ax.fill_between(df_gpsprobe.timestamp, df_gpsprobe.speed, 0, 
                where = (df_gpsprobe.timestamp >= 1643237118161) & (df_gpsprobe.timestamp <= 1643237119999), color = 'g')
plt.xlabel('timestamp (ms)')
plt.ylabel('speed (m/s)')
plt.show()

p2 = 1643237119999 enter image description here

p2 = 1643237120000 enter image description here

0 Answers
Related