Hello all,

I need help to have customize tick labels using axis artist.

My problem is to create a grid representation in polar co-ordinates (see fig) with r = logspace(log(1),log(120),128)

and theta = linspace(0.17,2.97,64) # in radians

I managed to to create the proper gridlines. But unfortunately I have to remove the tick labels as the way I describe the grid locator they crowd the axis.

I would like to choose only certain points on the axis and label them as the plot would look nice.

Regards

Bhargav Vaidya.

Here is my code modified to my need from already existing code found in the web :

from matplotlib.transforms import Affine2D

import mpl_toolkits.axisartist.floating_axes as floating_axes

import numpy as np

import mpl_toolkits.axisartist.angle_helper as angle_helper

from matplotlib.projections import PolarAxes

from mpl_toolkits.axisartist.grid_finder import FixedLocator, MaxNLocator, \

DictFormatter

def setup_axes2(fig, rect):

tr = PolarAxes.PolarTransform()

pi = np.pi

rad = np.logspace(np.log(1.),np.log(120.),128) # Radial

theta = np.linspace(0.17,2.97,64) # Theta Co-ordinates

angle_ticks = [(0, r"$\frac{1}{2}\pi$"),

(.25*pi, r"$\frac{1}{4}\pi$"),

(.5*pi, r"$0$"),

(-.25*pi, r"$\frac{3}{4}\pi$"),

(-0.5*pi, r"$\pi$")]

grid_locator1 = FixedLocator([j-0.5*pi for j in theta])

#grid_locator1 = FixedLocator([v for v, s in angle_ticks])

grid_locator2 = FixedLocator([i for i in rad])

grid_helper = floating_axes.GridHelperCurveLinear(tr,

extremes=(.5*pi-0.17, -.5*pi+0.17, 120, 1),

grid_locator1=grid_locator1,

grid_locator2=grid_locator2,

tick_formatter1=None,

tick_formatter2=None,

)

ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)

fig.add_subplot(ax1)

# create a parasite axes whose transData in RA, cz

aux_ax = ax1.get_aux_axes(tr)

aux_ax.patch = ax1.patch # for aux_ax to have a clip path as in ax

ax1.patch.zorder=0.9 # but this has a side effect that the patch is

# drawn twice, and possibly over some other

# artists. So, we decrease the zorder a bit to

# prevent this.

return ax1, aux_ax

if 1:

import matplotlib.ticker as mpltick

import matplotlib.pyplot as plt

fig = plt.figure(1, figsize=(10, 10))

ax2, aux_ax2 = setup_axes2(fig, 111)

ax2.axis["left"].major_ticklabels.set_visible(False)

ax2.axis["bottom"].major_ticklabels.set_visible(False)

ax2.grid(color='k',linestyle='-',linewidth=0.5)

plt.show()

Here is the eps file

Disk_grid.eps (190 KB)