Petr -
This question was asked by me and others a month or so ago, and nobody
replied with a way to do this (besides given the plot command multiple
times, of course). So for now I am afraid that that is your only
option. If anybody knows a better way, let us know please!
Mark
···
Message: 1
Date: Sat, 17 Sep 2005 02:16:25 +0200From: Petr <petr@…795…>
Reply-To: Petr <petr@…795…>
To: matplotlib-users@lists.sourceforge.netSubject: [Matplotlib-users] one line - multiple colors
Hi all,
I was investigating archives, but I didn’t find answer to my question.
I would like to plot the line which interconnects the GPS track points
(latitude and longitude coordinates) recorded by GPS receiver. It is
not so difficult. What I am not able to do is to change the color of
the line according to the speed reached on the way from point to
point. I would like to use the color of the line to differentiate thespeed as following:
speed <=50km/h
speed >50 and <=90km/h
speed >90 and <=130km/h
speed >130km/hAccording to the matplotlib web: “If you make multiple lines with one
plot command, the kwargs apply to all those lines”. So I am able toset the different color arguments while plotting the tuple of the x and y points.
I would like to get something like following code:
(data is not real of course, it is for demonstration purposes only)longitudes=[53.26,53.54,53.75,53.22]
latitudes=[18.56,18.72,18.93,18.12]
speeds=[‘r’,‘g’,‘y’,‘r’]
plot(latitudes,longitudes, speeds)
show()Many thks for your suggestions.
Petr Jakes