You are reading an old version of the documentation (v1.4.2). For the latest version see

Previous topic

axes_grid example code:

Next topic

axes_grid example code:

This Page

axes_grid example code: demo_curvelinear_grid2.pyΒΆ

(Source code, png, hires.png, pdf)

import numpy as np
#from matplotlib.path import Path

import matplotlib.pyplot as plt

from  mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
from mpl_toolkits.axes_grid.axislines import Subplot

import  mpl_toolkits.axes_grid.angle_helper as angle_helper

def curvelinear_test1(fig):
    grid for custom transform.

    def tr(x, y):
        sgn = np.sign(x)
        x, y = np.abs(np.asarray(x)), np.asarray(y)
        return sgn*x**.5, y

    def inv_tr(x,y):
        sgn = np.sign(x)
        x, y = np.asarray(x), np.asarray(y)
        return sgn*x**2, y

    extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
                                                     lon_cycle = None,
                                                     lat_cycle = None,
                                                     lon_minmax = None, #(0, np.inf),
                                                     lat_minmax = None,

    grid_helper = GridHelperCurveLinear((tr, inv_tr),

    ax1 = Subplot(fig, 111, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of
    # the Axes itself (i.e., transData) is not affected by the given
    # transform.


               vmax = 50,,

    # tick density
    grid_helper.grid_finder.grid_locator1._nbins = 6
    grid_helper.grid_finder.grid_locator2._nbins = 6

if 1:
    fig = plt.figure(1, figsize=(7, 4))


Keywords: python, matplotlib, pylab, example, codex (see Search examples)