how to make a polar plot just of a section with grid

Hello everyone,

I want to make a polar plot with grid not of the full circle but a
section (e.g. r=[5:6], phi=[-20:30]). The result should look like this:
http://homepages.physik.uni-muenchen.de/~Stefan.Mauerberger/example.png
I have tried a lot and had also looked to the examples but my results
are not satisfying. This example
http://matplotlib.sourceforge.net/examples/axes_grid/demo_curvelinear_grid.html seems to be highly relevant for my needs but i do not understand it at all.

I tried two different ways:
Using the option polar=True works fine but I was not able to shrink the
plot to the section.
Otherwise transforming the data to cartesian coordinates (e.g.
pcolor(r*np.sin(phi),r*np.cos(phi),data) ) the data are plotted into a
box. But in this case I do not know how to draw a grid.

Could anyone give me some advice how to do this?

Regards

Stefan

2010/10/20 Stefan Mauerberger <stefan.mauerberger@...3317...>:

I want to make a polar plot with grid not of the full circle but a
section (e.g. r=[5:6], phi=[-20:30]). The result should look like this:
http://homepages.physik.uni-muenchen.de/~Stefan.Mauerberger/example.png
I have tried a lot and had also looked to the examples but my results
are not satisfying. This example
http://matplotlib.sourceforge.net/examples/axes_grid/demo_curvelinear_grid.html seems to be highly relevant for my needs but i do not understand it at all.

I tried two different ways:
Using the option polar=True works fine but I was not able to shrink the
plot to the section.
Otherwise transforming the data to cartesian coordinates (e.g.
pcolor(r*np.sin(phi),r*np.cos(phi),data) ) the data are plotted into a
box. But in this case I do not know how to draw a grid.

I believe only option (2) will be feasible, I remember a discussion in
past about this to having had the same outcome.

Try here: http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.pcolor
(*faceted* option).

Notice the next functions on that page, they might help you saving
time, but some of them *might* not work in polar Axes, I'm not sure
which of them if any at all, just be warned.

Make sure you're using 1:1 aspect of the axes containing the pcolor()
Collection, or it will look distorted.

Friedrich

P.S.: If this is your first mpl-users thread, make sure to hit the
reply-to-all button ...

Hi Frederick,

thanks for your answer. The option *faceted* I already knew but this is
not exactly what I want. Perhaps it would be possible to draw the grid
without labels.

My goal is to draw a grid with labels above the data. Similar to the
example 'demo curvelinear grid'.

Regards

Stefan

2010/10/21 Stefan Mauerberger <stefan.mauerberger@...3317...>:

My goal is to draw a grid with labels above the data. Similar to the
example 'demo curvelinear grid'.

Ok, I think I cannot give you an authoritative response here, but the
following might be useful for the labels:

http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.text

From first glimple, I don't understand

http://matplotlib.sourceforge.net/examples/axes_grid/demo_curvelinear_grid.html
either. It assumes a lot of knowledge of the techniques used imo.

As a conclusion, I predict that this plot can easily grow to middle
complexity, and that it might be worth using PolarAxes with grid
turned off, and maybe save it as svg and remove the circle or sth like
that. AFAIK, lines in PolarAxes are automatically bended, so the grid
shouln't be a problem (you may use some pcolor function with nans in
the values, so that only the grid is drawn)

You can override the PolarAxes locator and ticklabels.

Friedrich