0

I am plotting 2 columns of a dataframe in this way:

fig, ax = plt.subplots()

ax.plot(df['Longitude'], df['Latitude'],
        color='darkorange', linewidth=5, alpha=0.5)
sub = 10
ax.quiver(df['Longitude'][::sub], df['Latitude'][::sub], df['u'][::sub], 
df['v'] [::sub], color='deepskyblue',
      alpha=0.4,
      scale=20)

mplleaflet.show(fig=fig, tiles='esri_worldtopo')

with this method I get this plot: My plot

I would like to change the style of this plot, in particular of based on another column I have in my df, named Speed:

   Longitude   Latitude    Altitude       Time         Speed
0  16.397203  43.536880     None 2018-06-28 16:35:11  5.401084
1  16.397195  43.536977     None 2018-06-28 16:35:13  3.717545
2  16.397198  43.537013     None 2018-06-28 16:35:15  3.912424
3  16.397215  43.537117     None 2018-06-28 16:35:17  4.115091
4  16.397230  43.537181     None 2018-06-28 16:35:20  6.151016

I would like to change the style of my ax.plot() generated line in a way that, for example, when the value of speed increases I have a darker color and vice versa, I tried to search on pandas and matplotlib documentation, but I did not find any useful information, where can I find some information on how to achieve this?

robsanna
  • 433
  • 1
  • 7
  • 16
  • This is covered in the documentation/example gallery: https://matplotlib.org/2.0.2/examples/pylab_examples/multicolored_line.html – Diziet Asahi Jul 17 '18 at 13:53
  • I saw that, but this doesnt help me. What I want to achieve is to color the line based on values I have in another column that is not plotted. – robsanna Jul 19 '18 at 12:39

0 Answers0