superimposition of Cartesian projection axis on a polar axis on the same position

Hi,

I have x-y grid data with z values and want to have a pixel view and contour view at the same time on the same position. Both cases should have polar coordinate system but since contour function does not plot on the polar coordinate system, it is plotted on a rectilinear projection with converting the polar grid into x-y grid. Please let me know if this isn’t true.

For pixel view, pcolormesh was used. The subplot was added with specifying the projection=‘polar’, as something like below:

axp=fig.add_subplot(1,1,1,projection=‘polar’)

axr=fig.add_subplot(2,2,1)

Then, I will have two independent axes shown in the figure canvas.

Since I want to place the two axes on the same position, if allowed, I would like to do:

axp=fig.add_subplot(1,1,1,projection=‘polar’)

axr=fig.add_subplot(1,1,1)

But it only gives one axis added to ‘fig.axes’.

Is there any work-around? Or am I missing some other feature of matplotlib?

Youngung

There are some ways to do this, but I haven’t tried them myself.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html

Ben Root

···

On Wed, Sep 14, 2011 at 3:08 PM, Youngung Jeong <youngung.jeong@…287…> wrote:

Hi,

I have x-y grid data with z values and want to have a pixel view and contour view at the same time on the same position. Both cases should have polar coordinate system but since contour function does not plot on the polar coordinate system, it is plotted on a rectilinear projection with converting the polar grid into x-y grid. Please let me know if this isn’t true.

For pixel view, pcolormesh was used. The subplot was added with specifying the projection=‘polar’, as something like below:

axp=fig.add_subplot(1,1,1,projection=‘polar’)

axr=fig.add_subplot(2,2,1)

Then, I will have two independent axes shown in the figure canvas.

Since I want to place the two axes on the same position, if allowed, I would like to do:

axp=fig.add_subplot(1,1,1,projection=‘polar’)

axr=fig.add_subplot(1,1,1)

But it only gives one axis added to ‘fig.axes’.

Is there any work-around? Or am I missing some other feature of matplotlib?

Youngung

Somehow, this is not clearly documented for the subplot command.
You need to use label parameter to create multiple axes at a same
position (for more details,
http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.add_axes)

axr=fig.add_subplot(1,1,1, label="r")
axp=fig.add_subplot(1,1,1,projection='polar', label="p")

Regards,

-JJ

···

On Thu, Sep 15, 2011 at 5:08 AM, Youngung Jeong <youngung.jeong@...287...> wrote:

But it only gives one axis added to 'fig.axes'.
Is there any work-around? Or am I missing some other feature of matplotlib?

I think this is not True, but I may misunderstood you. Can you post an
example that does not work? Here is a simple example that shows it
does work. But I hardly use polar coordinate, and my example could be
too simple.

ax = subplot(111, polar=True)

aa = np.indices((10,10))
x = np.linspace(0., np.pi*2, 10)
y = np.linspace(0., 10, 10)

ax.pcolormesh(x, y, aa[0], cmap="gray")
ax.contour(x, y, aa[0])

Both pcolormesh and contour gives a consistent result.

However, I think, while the resulting contour lines are drawn in polar
coordinate system, the actual contouring is done in rectlinear
cooridinate system. So there may be some caveats.

Regards,

-JJ

···

On Thu, Sep 15, 2011 at 5:08 AM, Youngung Jeong <youngung.jeong@...287...> wrote:

but since contour function does not plot on the polar coordinate system

You may better stick to the subplot with polar projection if your
original data is in polar coordinate.
The axislines module basically assumes that your data is in rectlinear
coordinate system. It only draws the gridlines and labels in
curvelinear system (although you can combine both).

Regards,

-JJ

···

On Thu, Sep 15, 2011 at 6:18 AM, Benjamin Root <ben.root@...1304...> wrote:

There are some ways to do this, but I haven't tried them myself.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html

Ben Root