CXX type errors help

Hi all,

I am a matplotlib novice and am having problems with imported floats
generated by a Perl script using the Maxmind Geo::IP library.

I keep getting CXX TypeErrors which I can not seem to eliminate.
Any pointers for this novice please?

I write files that return longitude and latitude and then generate a
plot script with the data set.

Many Thanks!

____________________minimally altered example plot script_______________

from matplotlib.toolkits.basemap import Basemap
import pylab as p
# set up orthographic map projection with
# perspective of satellite looking down at 50N, 100W.
# use low resolution coastlines.
# don' t plot features that are smaller than 1000 square km
map = Basemap(
  projection = 'ortho',
  lat_0 = 50,
  lon_0 = -100,
  resolution = 'c',
  area_thresh = 1000.
)
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.4)
map.drawcountries(linewidth=0.2)
map.fillcontinents( color = 'coral' )
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary()
# draw lat/lon grid lines every 30 degrees.
map.drawmeridians( p . arange( 0, 360, 30 ) )
map.drawparallels( p . arange( -90, 90, 30 ) )
# lat/lon coordinates of five cities.

##---------------------changes
#data [altered data set import from Maxmind Geo::IP lookups
lats=[-0.0000, 1096176317235200.0000, 31226649198326710000.0000, 0.0000,
0.0000]
lons=[3.0542, 3.0423, 3.1635, 3.1523, 3.1523]
cities=['Vienna US', 'Mountain View US', 'Derby GB', 'London GB',
'London GB']
##---------------------end chages

# compute the native map projection coordinates for cities.

#map floats
x,y = map(lons,lats)

# plot filled circles at the locations of the cities.
map.plot(x,y,'bo')

# plot the names of those five cities.
for name,xpt,ypt in zip(cities,x,y):
  #p.text(xpt+50000,ypt+50000,name)
  p.text(xpt,ypt,name)
p.show()

···

__________________________________________________

##########error trace##############################

Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
    return self.func(*args)
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\backends\backend_tkagg.py", line 151, in resize
    self.show()
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\backends\backend_tkagg.py", line 154, in draw
    FigureCanvasAgg.draw(self)
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\backends\backend_agg.py", line 392, in draw
    self.figure.draw(renderer)
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\figure.py", line 569, in draw
    for a in self.axes: a.draw(renderer)
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\axes.py", line 1155, in draw
    a.draw(renderer)
  File
"c:\python25\lib\site-packages\matplotlib-0.90.0-py2.5-win32.egg\matplotl
ib\text.py", line 414, in draw
    for line, wh, x, y in info:
TypeError: CXX: type error.

Stefan Kueppers wrote:

Hi all,

I am a matplotlib novice and am having problems with imported floats
generated by a Perl script using the Maxmind Geo::IP library.

I keep getting CXX TypeErrors which I can not seem to eliminate.
Any pointers for this novice please?

I write files that return longitude and latitude and then generate a
plot script with the data set.

Many Thanks!

____________________minimally altered example plot script_______________

from matplotlib.toolkits.basemap import Basemap
import pylab as p
# set up orthographic map projection with
# perspective of satellite looking down at 50N, 100W.
# use low resolution coastlines.
# don' t plot features that are smaller than 1000 square km
map = Basemap(
  projection = 'ortho',
  lat_0 = 50,
  lon_0 = -100,
  resolution = 'c',
  area_thresh = 1000.
)
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.4)
map.drawcountries(linewidth=0.2)
map.fillcontinents( color = 'coral' )
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary()
# draw lat/lon grid lines every 30 degrees.
map.drawmeridians( p . arange( 0, 360, 30 ) )
map.drawparallels( p . arange( -90, 90, 30 ) )
# lat/lon coordinates of five cities.

##---------------------changes
#data [altered data set import from Maxmind Geo::IP lookups
lats=[-0.0000, 1096176317235200.0000, 31226649198326710000.0000, 0.0000,
0.0000]
lons=[3.0542, 3.0423, 3.1635, 3.1523, 3.1523]
cities=['Vienna US', 'Mountain View US', 'Derby GB', 'London GB',
'London GB']
##---------------------end chages

# compute the native map projection coordinates for cities.

#map floats
x,y = map(lons,lats)

# plot filled circles at the locations of the cities.
map.plot(x,y,'bo')

# plot the names of those five cities.
for name,xpt,ypt in zip(cities,x,y):
  #p.text(xpt+50000,ypt+50000,name)
  p.text(xpt,ypt,name)
p.show()

Stefan: The lons and lats must be specified in degrees. I don't know what units you are getting from Geo::IP, but they sure aren't degrees.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328