I am trying to plot the energy consumption profile of an electric vehicle. I am using the elevation profile vs the horizontal distance the vehicle runs along a path. I want to add a second x-axis on top of the plot to represent by each chunk of distance, what the energy consumption value was at that precise location.
This is what I have so far, but it's not precisely what I need:
I know this should be fairly simple as it is only adding a second x-axis that matches with the primary x-axis, but I have wasted an entire day trying to figure out unsuccessfully :(
Any insights will be greatly appreciated.
Code:
fig, ax1 = plt.subplots()
elevation_distance_np = elevation_distance.to_numpy()
plt.plot(elevation_distance_np[:,0], elevation_distance_np[:,1], color = 'blue')
plt.grid(True)
plt.xlabel("Distancia recorrida")
plt.ylabel("Elevación de distancia recorrrida")
axes2 = ax1.twiny()
axes2.set_xticks(suma_kWh_np[::mth.ceil(len(suma_kWh_np)/8)])
plt.title("Elevación vs Distancia Recorrida")
plt.show()