On 5/24/10 8:45 AM, Benjamin Root wrote:


On Fri, May 21, 2010 at 5:16 PM, Jeff Whitaker <jsw...@fastmail.fm <mailto:jsw...@fastmail.fm>> wrote:


    On 5/21/10 3:57 PM, Benjamin Root wrote:
    I did some more digging and I think I have a hypothesis for what
    is happening.

    There is only one main difference between a call to .drawstates()
and .readshapefiles() with respect to loading and plotting data. .drawstates() loads *only* the line segments that coincide with
    the defined map boundaries, while .readshapefiles() loads all of
    the data in the shapefile.  Therefore, the LineCollection that
    gets attached to the axis contains data from outside the stated
    domain.

    In addition, the basemap versions of the plotting functions have
    the benefit of finishing their calls with a call to
    .set_axes_limits(), which keeps the axes in check.  However, a
    non-basemap version would not call that automatically, thereby
    having its axes automatically expanded to contain all of the data
    in the LineCollection.

    I am not sure what exactly should be done about this.  This is
    certainly un-intuitive behavior, though. Maybe there could be a
    keyword option in .readshapefile() to have only the data for the
    stated domain loaded?  That might solve the issue.

    Thanks,
    Ben Root

    Ben:  That's why you should use the basemap methods where possible
    (they handle these things for you).


Yeah, that wasn't possible in my case. In addition, not all pyplot plotting functions are available (nor do I expect Basemap to have all of them available). Therefore, it often makes more sense for me to use the pyplot functions and just give Basemap the axes.

    You could also turn autoscaling off on your axes using

    ax.set_autoscaleon(False)

    and then they won't automatically expand when you plot data
    outside your map region.  Or, you could just call the
    set_axes_limits() methods before you draw the plot.

At the least, I think this advice should be thoroughly documented, especially in the docstring for readshapefile(). This behavior was quite perplexing to me and it took a while to figure out the cause. I am one of those people who will not leave well enough alone...


    Clipping the polygons to the map projection region is non-trivial,
    and I don't think I want to add that to readshapefile.

Personally, I think there should be a family of .draw*() functions that behave like .drawstates(). One of those functions can be .drawshapefile(). Then there would be a family of .read*() functions that could be called either by the user or by the .draw*() functions. The .read*() function could have an option to perform a clip of the incoming data.

If you like to discuss this further, I would be more than happy to help out.

Ben Root
Ben: The shapefile stuff in Basemap certainly could use some work. If you'd like to help, that would be great.

-Jeff

--
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : jeffrey.s.whita...@noaa.gov
325 Broadway                Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg

------------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to