I have two list as below:
latt=[42.0,41.978567980875397,41.96622693388357,41.963791391892457,...,41.972407378075879]
lont=[-66.706920989908909,-66.703116557977069,-66.707351643324543,...-66.718218142021925]
now I want to plot this as a line, separate each 10 of those 'latt' and 'lont' records as a period and give it a unique color. what should I do?
Copied from this example:
See the answer here to generate the "periods" and then use the matplotlib scatter function as @tcaswell mentioned. Using the plot.hold function you can plot each period, colors will increment automatically.
There are several different ways to do this. The "best" approach will depend mostly on how many line segments you want to plot.
If you're just going to be plotting a handful (e.g. 10) line segments, then just do something like:
If you're plotting something with a million line segments, though, this will be terribly slow to draw. In that case, use a
LineCollection
. E.g.For both of these cases, we're just drawing random colors from the "gist_ncar" coloramp. Have a look at the colormaps here (gist_ncar is about 2/3 of the way down): http://matplotlib.org/examples/color/colormaps_reference.html
Cribbing the color choice off of @JoeKington,
You can do this with
scatter
.