Re: [Matplotlib-users] Mac OSX 64bit

2011-10-03 Thread Benjamin Root
> Does the installation page needs updating?
> http://matplotlib.sourceforge.net/users/installing.html#building-on-osx


Yes.  I made several changes to those docs for the v1.1.0 release.
Hopefully, it will make things clearer.

Ben Root
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] color problems in scatter plot

2011-10-03 Thread Michael Castleton

Hello,
I am using Matplotlib 1.0.0 in Python 2.6.
I am trying to plot time series data of unique IDs and color the points
based on location. Each data point has a unique ID value, a date value, and
a location value.
The unique IDs and date values are plotting fine but I am unable to control
the color and subsequently the legend.

Here is a sample of the data.
IDs = [47, 33, 47, 12, 50, 50, 27, 27, 16, 27]
locations = ['201', '207', '207', '205', '204', '201', '209', '209',
'207','207']
dates = [ 733315.83240741,  733315.83521991,  733315.83681713,
733315.83788194,  76.54554398,  76.54731481,
77.99842593,  77.99943287,  78.00070602,
78.00252315]

This basic code works.

fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(dates,IDs,marker='d')
ax.xaxis_date()
fig.autofmt_xdate()
plt.grid(True)
plt.show()

I've been trying to figure out how to set color = locations with no success.
Any ideas out there?
Thanks,

Mike
-- 
View this message in context: 
http://old.nabble.com/color-problems-in-scatter-plot-tp32584727p32584727.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Animated matplotlib in wxPython, sizing / redrawing quirk

2011-10-03 Thread John Ladasky
Hi, folks,

I will be posting this question to both matplotlib-users and
wxpython-users.  Apologies to those of you who have to endure my
ramblings two times in a row!

Using this example by John Bender,

http://www.scipy.org/Matplotlib_figure_in_a_wx_panel

I recently constructed a working, animated matplotlib graph in a
wxPython frame.  A sample output is here:

http://www.flickr.com/photos/15579975@N00/6145518550

In that example, the text block is in wxPython, and the color bar for
the graph's Z scale is a bitmap object which is again handled by wx.
Only the live graph is rendered by matplotlib.
  
Once I accomplished this, I attempted a more complicated,
multiple-subplot display, this time with the text boxes handled my
matplotlib rather than wx.  I also tried removing parts of Mr. Bender's
code that I thought that I would not need.  Specifically, I've disabled
resizing of my matplotlib panel.  But when I removed the code associated
with sizing, I discovered that my animation disappeared.  The first
frame would draw, then nothing.

Digging deeper, I learned that redrawing is SOMEHOW accomplished in the
PlotPanel._SetSize method.  _SetSize is called when there's a wx.IDLE
message.  In _SetSize, you have to call PlotPanel.SetSize (note, no
underscore this time) and FigureCanvasWxAgg.SetSize on EVERY cycle to
make animation work.  The matplotlib figure.set_size method needs only
to be called the first time -- at least, in my case, where I've disabled
resizing.  I haven't tested a resizable window.

Here are my questions.

1) I do not recall seeing this kind of behavior in wxPython before.  Why
does wxPython treat matplotlib objects differently?

2) How exactly is sizing making the redrawing happen?  Is this a good
method to use?  The indirect nature of this redrawing-by-sizing approach
sent me on a long and pointless hunt for bugs in my own code.  Finally,
how can I determine how MUCH redrawing is taking place on my matplotlib
canvas?  I am trying to implement eight image plots simultaneously, with
some overlaid contours, and some live text, too.   But sometimes I only
have to update four of the eight plots, or just the text.  Does
matplotlib know which parts of its image are "dirty" and confine its
updates appropriately?

Many thanks for your insights!




--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib - fill open path inside U.S. borders - set_clip_path appro ach

2011-10-03 Thread Isidora
Hi again,

still trying to accomplish the filling of certain paths only inside U.S.  It 
ocurred to me that set_clip_path could work but so far, I have not been able to 
 show the curve in the map. 

Could someone point out what is missing?  Thanks

#!/usr/bin/env python
"""http://www.scipy.org/Cookbook/Finding_Convex_Hull""";
import numpy as n, pylab as p, time
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.path as mpath
 
from matplotlib.patches import Polygon
from mpl_toolkits.basemap import Basemap
import sys
import numpy as np
import matplotlib.cm as cm
 
def _angle_to_point(point, centre):
'''calculate angle in 2-D between points and x axis'''
delta = point - centre
res = n.arctan(delta[1] / delta[0])
if delta[0] < 0:
res += n.pi
return res
 
 
def _draw_triangle(p1, p2, p3, **kwargs):
tmp = n.vstack((p1,p2,p3))
x,y = [x[0] for x in zip(tmp.transpose())]
p.fill(x,y, **kwargs) # commented out to see result
 
 
def area_of_triangle(p1, p2, p3):
'''calculate area of any triangle given co-ordinates of the corners'''
return n.linalg.norm(n.cross((p2 - p1), (p3 - p1)))/2.
 
 
def convex_hull(points, graphic=True, smidgen=0.0075):
'''Calculate subset of points that make a convex hull around points
 
Recursively eliminates points that lie inside two neighbouring points until 
only convex hull is remaining.
 
:Parameters:
points : ndarray (2 x m)
array of points for which to find hull
   graphic : bool
use pylab to show progress?
smidgen : float
offset for graphic number labels - useful values depend on your data 
range
 
:Returns:
hull_points : ndarray (2 x n)
convex hull surrounding points
'''
# Commenting these 2 lines out shows the plotting of the country border
#if graphic:
#p.clf()
n_pts = points.shape[1]
print "POINTS shape[1]:%d" %(n_pts)
assert(n_pts > 5)
centre = points.mean(1)
angles = n.apply_along_axis(_angle_to_point, 0, points, centre)
pts_ord = points[:,angles.argsort()]
pts = [x[0] for x in zip(pts_ord.transpose())]
prev_pts = len(pts) + 1
k = 0
while prev_pts > n_pts:
prev_pts = n_pts
n_pts = len(pts)
if graphic: p.gca().patches = []
i = -2
while i < (n_pts - 2):
Aij = area_of_triangle(centre, pts[i], pts[(i + 1) % n_pts])
Ajk = area_of_triangle(centre, pts[(i + 1) % n_pts], \
   pts[(i + 2) % n_pts])
Aik = area_of_triangle(centre, pts[i], pts[(i + 2) % n_pts])
if Aij + Ajk < Aik:
if graphic: p.plot((pts[i + 1][0],),(pts[i + 1][1],))  # 
without green circle marker
del pts[i+1]
i += 1
n_pts = len(pts)
k += 1
return n.asarray(pts)
 
if __name__ == "__main__":
x1 = -124.
x2 = -57.
y1 = 18.
y2 = 51.
 
m = Basemap(resolution='i',projection='stere', lat_0=39., 
lon_0=-98.,llcrnrlat=y1,urcrnrlat=y2,llcrnrlon=x1,urcrnrlon=x2)
point0 = []
point1 = []
cpaths = (m.drawcountries()).get_paths()
for cpath in cpaths:
vs = cpath.vertices
for v in vs:
x=v[0]
y=v[1]
point0.append(x)
point1.append(y)
nonumpy = []
nonumpy.append(point0)
nonumpy.append(point1)
points = n.array(nonumpy)
hull_pts = convex_hull(points)
poly = Polygon(hull_pts)
USpath = poly.get_path()
USpatch = mpatches.PathPatch(USpath,facecolor='none',edgecolor='none')
ax = plt.gca()
ax.add_patch(USpatch)
 
# Add my curve
Path = mpath.Path
pathdata = []
pathdata.append((Path.MOVETO,m(-120.,35.)))
pathdata.append((Path.LINETO,m(-100.,35.)))
pathdata.append((Path.LINETO,m(-100.,30.)))
pathdata.append((Path.LINETO,m(-90.,28.)))
pathdata.append((Path.LINETO,m(-90,25)))
pathdata.append((Path.LINETO,m(-100,25)))
pathdata.append((Path.CURVE3,m(-120.,35.)))
 
codes,verts = zip(*pathdata)
   im = ax.imshow(verts,cmap=cm.gray,clip_path=USpatch,clip_on=True)
im.set_clip_path(USpatch)
m.drawparallels(np.arange(20,60,5),labels=[1,0,0,0],color='black')
m.drawmeridians(np.arange(-140,60,10),labels=[0,0,0,1],color='black')
plt.gcf().savefig('./ch.png')



--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] twinx problem

2011-10-03 Thread Christopher Brown
Hi,

Im running mpl 1.01 from sf installer with py2.7 on windows xp. Can 
anyone tell me what I am doing wrong in the following snippet:

import matplotlib.pyplot as pp
fig = pp.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
# works (tick labels are blue):
for tick in ax1.yaxis.get_major_ticks():
 tick.label1.set_color('blue')
# does not work (tick labels are not red):
for tick in ax2.yaxis.get_major_ticks():
 tick.label1.set_color('red')
pp.show()

-- 
Christopher Brown, Ph.D.
Associate Research Professor
Department of Speech and Hearing Science
Arizona State University
http://pal.asu.edu

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot arrows for wind direction (degrees)

2011-10-03 Thread questions anon
Hi All,
Is there a simple way to plot a directional arrow to represent a degree?
I have a netcdf file containing wind direction as degrees and I would like
to make a plot with all little arrows representing the wind direction.
Below is the code I am using currently to plot wind direction but am not
sure where/how to add directional arrows.
Thanks


from netCDF4 import Dataset
import numpy as N
import pylab as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
import os

ncfile=Dataset('E:/WINDDIR/IDZ00026_VIC_ADFD_Wind_Dir_SFC.nc', 'r+',
'NETCDF4')
WDIR=ncfile.variables['Wind_Dir_SFC'][-50]
LAT=ncfile.variables['latitude'][:]
LON=ncfile.variables['longitude'][:]
TIME=ncfile.variables['time'][-50]
fillvalue=ncfile.variables['Wind_Dir_SFC']._FillValue
WDIR=MA.masked_values(WDIR, fillvalue)
ncfile.close()

map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
  llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
x,y=map(*N.meshgrid(LON,LAT))
map.drawstates()
map.drawcoastlines()
plt.title('Wind Direction')
CS = map.contourf(x,y,WDIR,15, cmap=plt.cm.jet)
l,b,w,h =0.1,0.1,0.8,0.8
cax = plt.axes([l+w+0.025, b, 0.025, h])
plt.colorbar(CS,cax=cax,drawedges=True)
plt.savefig((os.path.join('E:/WINDDIR/', 'WDIRSFC.png')))
plt.show()
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] twinx problem

2011-10-03 Thread Benjamin Root
On Mon, Oct 3, 2011 at 2:22 PM, Christopher Brown  wrote:

> Hi,
>
> Im running mpl 1.01 from sf installer with py2.7 on windows xp. Can
> anyone tell me what I am doing wrong in the following snippet:
>
> import matplotlib.pyplot as pp
> fig = pp.figure()
> ax1 = fig.add_subplot(111)
> ax2 = ax1.twinx()
> # works (tick labels are blue):
> for tick in ax1.yaxis.get_major_ticks():
> tick.label1.set_color('blue')
> # does not work (tick labels are not red):
> for tick in ax2.yaxis.get_major_ticks():
> tick.label1.set_color('red')
> pp.show()
>
>
Confirmed with the v1.1.x branch as well.  Although, I don't play with
twinx() enough to know if this is really a bug or not, but my vote is that
it is a bug.

Ben Root
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] twinx problem

2011-10-03 Thread Eric Firing
On 10/03/2011 09:22 AM, Christopher Brown wrote:
> import matplotlib.pyplot as pp
> fig = pp.figure()
> ax1 = fig.add_subplot(111)
> ax2 = ax1.twinx()
> # works (tick labels are blue):
> for tick in ax1.yaxis.get_major_ticks():
>   tick.label1.set_color('blue')
> # does not work (tick labels are not red):
> for tick in ax2.yaxis.get_major_ticks():
>   tick.label1.set_color('red')
> pp.show()


Try this instead:

import matplotlib.pyplot as pp
fig = pp.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
ax1.tick_params(axis='y', labelcolor='b')
ax2.tick_params(axis='y', labelcolor='r')
pp.show()

Eric

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot arrows for wind direction (degrees)

2011-10-03 Thread Benjamin Root
On Mon, Oct 3, 2011 at 6:51 PM, questions anon wrote:

> Hi All,
> Is there a simple way to plot a directional arrow to represent a degree?
> I have a netcdf file containing wind direction as degrees and I would like
> to make a plot with all little arrows representing the wind direction.
> Below is the code I am using currently to plot wind direction but am not
> sure where/how to add directional arrows.
> Thanks
>
>
> from netCDF4 import Dataset
> import numpy as N
> import pylab as plt
> from numpy import ma as MA
> from mpl_toolkits.basemap import Basemap
> import os
>
> ncfile=Dataset('E:/WINDDIR/IDZ00026_VIC_ADFD_Wind_Dir_SFC.nc', 'r+',
> 'NETCDF4')
> WDIR=ncfile.variables['Wind_Dir_SFC'][-50]
> LAT=ncfile.variables['latitude'][:]
> LON=ncfile.variables['longitude'][:]
> TIME=ncfile.variables['time'][-50]
> fillvalue=ncfile.variables['Wind_Dir_SFC']._FillValue
> WDIR=MA.masked_values(WDIR, fillvalue)
> ncfile.close()
>
> map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
>   llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
> x,y=map(*N.meshgrid(LON,LAT))
> map.drawstates()
> map.drawcoastlines()
> plt.title('Wind Direction')
> CS = map.contourf(x,y,WDIR,15, cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h])
> plt.colorbar(CS,cax=cax,drawedges=True)
> plt.savefig((os.path.join('E:/WINDDIR/', 'WDIRSFC.png')))
> plt.show()
>
>
Would the barb() command do what you want?

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.barbs
http://matplotlib.sourceforge.net/examples/pylab_examples/barb_demo.html

They aren't arrows, but they are commonly used in meteorology to plot
windfields.

Cheers,
Ben Root
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Animated matplotlib in wxPython, sizing / redrawing quirk

2011-10-03 Thread John Ladasky
Following up to my own post:

First, Sourceforge's listserv did not like the link to my animation.
Let my try again, with a shortened link:

http://flic.kr/p/an4oyo


Second:

> The indirect nature of this redrawing-by-sizing approach
> sent me on a long and pointless hunt for bugs in my own code.

Putting this another way -- explicit is better than implicit!


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot arrows for wind direction (degrees)

2011-10-03 Thread Eric Firing
On 10/03/2011 03:00 PM, Benjamin Root wrote:
> On Mon, Oct 3, 2011 at 6:51 PM, questions anon  > wrote:
>
> Hi All,
> Is there a simple way to plot a directional arrow to represent a degree?
> I have a netcdf file containing wind direction as degrees and I
> would like to make a plot with all little arrows representing the
> wind direction.
> Below is the code I am using currently to plot wind direction but am
> not sure where/how to add directional arrows.
> Thanks
>
>
> from netCDF4 import Dataset
> import numpy as N
> import pylab as plt
> from numpy import ma as MA
> from mpl_toolkits.basemap import Basemap
> import os
>
> ncfile=Dataset('E:/WINDDIR/IDZ00026_VIC_ADFD_Wind_Dir_SFC.nc', 'r+',
> 'NETCDF4')
> WDIR=ncfile.variables['Wind_Dir_SFC'][-50]
> LAT=ncfile.variables['latitude'][:]
> LON=ncfile.variables['longitude'][:]
> TIME=ncfile.variables['time'][-50]
> fillvalue=ncfile.variables['Wind_Dir_SFC']._FillValue
> WDIR=MA.masked_values(WDIR, fillvalue)
> ncfile.close()
>
> map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
>llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
> x,y=map(*N.meshgrid(LON,LAT))
> map.drawstates()
> map.drawcoastlines()
> plt.title('Wind Direction')
> CS = map.contourf(x,y,WDIR,15, cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h])
> plt.colorbar(CS,cax=cax,drawedges=True)
> plt.savefig((os.path.join('E:/WINDDIR/', 'WDIRSFC.png')))
> plt.show()
>
>
> Would the barb() command do what you want?
>
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.barbs
> http://matplotlib.sourceforge.net/examples/pylab_examples/barb_demo.html
>
> They aren't arrows, but they are commonly used in meteorology to plot
> windfields.
>
> Cheers,
> Ben Root

There is also quiver, both in matplotlib and in basemap.  See the 
quiver_demo.py and barb_demo.py in the basemap examples directory.

Eric

>
>
>
> --
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
>
>
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] twinx problem

2011-10-03 Thread Jae-Joon Lee
On Tue, Oct 4, 2011 at 4:22 AM, Christopher Brown  wrote:
>     tick.label1.set_color('red')
>

You should use tick.label2, not tick.label1.

tick.label2.set_color('red')

Anyhow, as Eric said, it is strongly advised to use the tick_params method.

-JJ

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] color problems in scatter plot

2011-10-03 Thread Ryan Nelson
Mike, sorry to send this twice... I should have sent it to the list as
well...
___
Mike,

If your locations were integers or floats rather than strings, you could
just change the scatter call to the following:
ax.scatter(dates,IDs,c=
locations,marker='d')
I don't know about a legend... I don't know if that is possible with a
scatter plot (?). Because scatter plots get their colors based off of a
color map, you could generate a color bar for your data. You may need to
capture the collection object returned from the scatter plot function call,
though. Here's your code with these modifications:

# Of course, you need to change your locations list to integers rather than
strings.

fig = plt.figure()
ax = fig.add_subplot(111)
sc = ax.scatter(dates,IDs,c=locations,marker='d')
ax.xaxis_date()
fig.autofmt_xdate()
plt.colorbar(sc)
plt.grid(True)
plt.show()

If you really need a legend, then you could do a loop of plot commands for
each set of unique locations. Using some fancy Numpy masking makes the
process easier...

import numpy as np
import matplotlib.pyplot as plt

IDs = np.array([47, 33, 47, 12, 50, 50, 27, 27, 16, 27])
locations = np.array(['201', '207', '207', '205', '204', '201', '209',
'209', \
'207','207'])
dates = np.array([ 733315.83240741,  733315.83521991,  733315.83681713,

   733315.83788194,  76.54554398,  76.54731481,
   77.99842593,  77.99943287,  78.00070602,
   78.00252315])


fig = plt.figure()
ax = fig.add_subplot(111)
cs = ['r', 'b', 'g', 'k', 'c']
for n, i in enumerate(np.unique(locations)):
ax.plot(dates[locations==i],IDs[locations==i],'d', c=cs[n%len(cs)],
label=i)
ax.xaxis_date()
fig.autofmt_xdate()
plt.legend(numpoints=1)
plt.grid(True)
plt.show()

Not sure if this is exactly what you wanted, but I hope it helps a little.

Ryan


On Mon, Oct 3, 2011 at 2:49 PM, Michael Castleton wrote:

>
> Hello,
> I am using Matplotlib 1.0.0 in Python 2.6.
> I am trying to plot time series data of unique IDs and color the points
> based on location. Each data point has a unique ID value, a date value, and
> a location value.
> The unique IDs and date values are plotting fine but I am unable to control
> the color and subsequently the legend.
>
> Here is a sample of the data.
> IDs = [47, 33, 47, 12, 50, 50, 27, 27, 16, 27]
> locations = ['201', '207', '207', '205', '204', '201', '209', '209',
> '207','207']
> dates = [ 733315.83240741,  733315.83521991,  733315.83681713,
>733315.83788194,  76.54554398,  76.54731481,
>77.99842593,  77.99943287,  78.00070602,
>78.00252315]
>
> This basic code works.
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.scatter(dates,IDs,marker='d')
> ax.xaxis_date()
> fig.autofmt_xdate()
> plt.grid(True)
> plt.show()
>
> I've been trying to figure out how to set color = locations with no
> success.
> Any ideas out there?
> Thanks,
>
> Mike
> --
> View this message in context:
> http://old.nabble.com/color-problems-in-scatter-plot-tp32584727p32584727.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
>
> --
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users