16

I have a collection of latitude/longitude points that straddle the longitude=0 line. I'd like to plot these using a matplotlib Axes class that "wraps" the horizontal dimension such that, when looking towards l=360, points at l=1 are plotted at the equivalent of l=361. Ideally, I'd also like something that defines the pan/zoom actions so I can use the plot interactively.

I know that it is possible to define custom projections in matplotlib, but I haven't found the equivalent of a Cylindrical projection that implements all of this functionality. I'd rather not use basemap. Does anyone know if something like this exists somewhere?

mgilson
  • 300,191
  • 65
  • 633
  • 696
ChrisB
  • 4,628
  • 7
  • 29
  • 41
  • I have with a similar problem ( [0,2\pi] data]) and deal with it by pre-processing the data to be in the range I want, but an axes class that does in automagically would be great. – tacaswell Aug 24 '12 at 22:20
  • Do you not want to use ``basemap`` because it doesn't do what you want, or for some other reason? – pelson Sep 04 '12 at 22:03
  • 1
    I'm looking for something that depends only on matplotlib core, and not an external toolkit like basemap – ChrisB Sep 05 '12 at 14:15
  • This functionality would be really useful! – Dan Nov 16 '12 at 14:44
  • Is it such a bad idea to use polar coordinates? Does your coordinate system have to be carthesian? – Thorsten Kranz Jan 03 '13 at 15:49

1 Answers1

2

You can get exactly what you are asking for by modifying the mathplotlib exapmle - api example code: custom_projection_example.py you just need to decide if you would like a spherical representation or cylindrical - if the latter then you may find more useful code in the custom_scale_example.py which also includes panning and zooming but in the example deliberatly limits the data to +-90 degrees - you will need to wrap instead.

Spherical Plot enter image description here

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
  • Addressed the lack of panning and zooming by pointing out another example that is specific to cylindrical projection and includes panning and zooming. – Steve Barnes Aug 04 '13 at 09:08
  • 1
    These are nice references, but still not the solution I'm looking for. Like you say, the code in custom_scale_example manually wraps the data to -180->+180. The question asks whether it's possible to set up MPL projections such that data in a range like [0, 360] can be auto-wrapped on the fly, depending on the view window (think google.com/maps at the widest zoom setting) – ChrisB Aug 05 '13 at 14:41
  • 2
    @ChrisB Correction custom_scale explicitly limits the data to -85..+85 degrees. The answer is Yes it is possible to do - I have to actually get on with some paying work but __you__ _should_ be able to adapt one of the examples above - with help from the other one - in a reasonably short time, (I would estimate 2-3 hours modifying and testing). – Steve Barnes Aug 06 '13 at 06:55
  • Although no full-blown jackpot, it is worth the bounty. – ojdo Aug 06 '13 at 20:21
  • Thank-you - I may revisit when I have some time on my hands. – Steve Barnes Aug 06 '13 at 20:22