The Axes class of the axisartist toolkit uses very different way to
handle ticks and tick labels. Thus most of the tick-related commands
of original matplotlib do not work!

Unfortunately, there is no easy way to support a logarithmic scale.

To utilize the full functionality, you need to create a transform
object and provide an appropriate tick locator. The first part is easy
but the second part is not. You can use origial mapltolib's tick
locator, but it has a limitation that minor ticks are not well
supported.

The easiest way is to convert your data to log scale and use a fixed
locator with a custom formatter. An example script is attached.

The better approach is to create your own locator and formatter.

Regards,

-JJ


On Fri, Apr 22, 2011 at 1:49 AM, Junghun Shin
<jhs...@ef.eie.eng.osaka-u.ac.jp> wrote:
> Hi, everyone.
>
> Let me explain what I wanted to do: First, I wanted to make a polar
> plot with angles from 0 to 90. I could do it by adopting the
> curvelinear grid demo ( http://goo.gl/kruXf ). And then I wanted to
> present the radius in log10 scale. But setting the plot command to
> semilogy or trying to set 'set_rscale('log')' all failed. Below I
> pasted the code that works for radius in linear scale.
>
> [Code]
> #!/usr/bin/env python
> import matplotlib.pyplot as plt
> import numpy as np
>
> #Modified from 
> http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/demo_floating_axis.py
>
> #def curvelinear_test2(fig, lp_r, lp_t):
> def curvelinear_test2(fig, lp_t, lp_r, rLower, rUpper):
>    rmin = np.min(lp_r)
>    rmax = np.max(lp_r)
>    print 'rm: ', rmin, 'rM: ', rmax,'rL: ', rLower, 'rU: ', rUpper
>    """
>    polar projection, but in a rectangular box.
>    """
>    global ax1
>    import  mpl_toolkits.axisartist.angle_helper as angle_helper
>    from matplotlib.projections import PolarAxes
>    from matplotlib.transforms import Affine2D
>
>    from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans
>
>    from mpl_toolkits.axisartist import GridHelperCurveLinear
>
>    from  mpl_toolkits.axisartist.grid_helper_curvelinear import
> GridHelperCurveLinear
>
>
>    # see demo_curvelinear_grid.py for details
>    tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
>
>    extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
>                                                     lon_cycle = 360,
>                                                     lat_cycle = None,
>                                                     lon_minmax = (0, 360),
>                                                     lat_minmax =
> (-np.inf, np.inf),
>                                                     #lat_minmax =
> (rmin, np.inf),
>                                                     )
>
>    grid_locator1 = angle_helper.LocatorDMS(12)
>
>    tick_formatter1 = angle_helper.FormatterDMS()
>
>    grid_helper = GridHelperCurveLinear(tr,
>                                        extreme_finder=extreme_finder,
>                                        grid_locator1=grid_locator1,
>                                        tick_formatter1=tick_formatter1
>                                        )
>
>
>    ax1 = SubplotHost(fig, 1, 1, 1, grid_helper=grid_helper)
>
>    fig.add_subplot(ax1)
>
>    # make ticklabels of all axis visible.
>    ax1.axis[:].major_ticklabels.set_visible(True)
>    #ax1.axis["top"].major_ticklabels.set_visible(True)
>    #ax1.axis["left"].major_ticklabels.set_visible(True)
>    #ax1.axis["bottom"].major_ticklabels.set_visible(True)
>
>    # show angle (0) at right and top
>    ax1.axis["right"].get_helper().nth_coord_ticks=0
>    ax1.axis["top"].get_helper().nth_coord_ticks=0
>
>    # show radius (1) at left and bottom
>    ax1.axis["left"].get_helper().nth_coord_ticks=1
>    ax1.axis["bottom"].get_helper().nth_coord_ticks=1
>
>    # set labels
>    ax1.axis["left"].label.set_text(r'ylabel')
>    ax1.axis["bottom"].label.set_text(r'xlabel')
>    ax1.axis["bottom"].major_ticklabels.set_rotation(-30)
>
>    ax1.set_aspect(1.)
>    ax1.set_xlim(rLower, rUpper)
>    ax1.set_ylim(rLower, rUpper)
>    #ax1.rscale('log')
>
>    # A parasite axes with given transform
>    ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
>    # note that ax2.transData == tr + ax1.transData
>    # Anthing you draw in ax2 will match the ticks and grids of ax1.
>    ax1.parasites.append(ax2)
>
>    ax2.plot(lp_t, lp_r, 'o-')
>    #ax2.semilogy(lp_t, lp_r, 'o-')
>    #ax2.set_rscale('log')
>    #ax1.set_xscale('log')
>    #ax1.set_yscale('log')
>
>    ax1.grid(True)
>
> if __name__ == "__main__":
>
>   fig = plt.figure(1, figsize=(5, 5))
>   fig.clf()
>
>   rmin = 1e-1
>   rmax = 1e2
>   lp_t = np.linspace(0., 90., 5)
>   lp_r = np.linspace(rmin, rmax/10, 5)*5
>
>   print "lp_t: ", lp_t
>   print "lp_r: ", lp_r
>   print "log10(lp_r): ", np.log10(lp_r)
>
>   curvelinear_test2(fig, lp_t, lp_r, rmin, rmax)
>   #curvelinear_test2(fig, lp_t, np.log10(lp_r), np.log10(rmin), np.log(rmax))
>
>   plt.show()
>
> [/Code]
>
> I'm using Enthought Python Distribution Version: 7.0-2 (32-bit) Python
> 2.7.1 on win32
> and matplotlib.__version__ is '1.0.1'.
>
> Thanks,
> Junghun Shin
> --
> Division of Electrical, Electronic and Information Engineering,
> Graduate School of Engineering, Osaka University,
> 2-6 Yamada-oka, Suita-shi, Osaka, 565-0871, JAPAN
> Tel / Fax: +81-6-6879-8755
> E-mail: jhs...@ef.eie.eng.osaka-u.ac.jp
> Group Homepage: http://www.eie.eng.osaka-u.ac.jp/ef/
>
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

Attachment: testet0.py
Description: Binary data

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to