import mpl_toolkits.axisartist as AA
from mpl_toolkits.axes_grid1 import host_subplot
host = host_subplot(111, axes_class=AA.Axes)
import mpl_toolkits.axisartist as AA
fig = plt.figure()
fig.add_axes([0.1, 0.1, 0.8, 0.8], axes_class=AA.Axes)
fig.add_subplot(111, axes_class=AA.Axes)
# Given that 111 is the default, one can also do
fig.add_subplot(axes_class=AA.Axes)
ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
ax.axis["y=0"] = ax.new_floating_axis(nth_coord=0, value=0)
# make new (right-side) yaxis, but with some offset
ax.axis["right2"] = ax.new_fixed_axis(loc="right", offset=(20, 0))
import mpl_toolkits.axisartist.angle_helper as angle_helper
# PolarAxes.PolarTransform takes radian. However, we want our coordinate
# system in degree
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
# extreme finder: find a range of coordinate.
# 20, 20: number of sampling points along x, y direction
# The first coordinate (longitude, but theta in polar)
# has a cycle of 360 degree.
# The second coordinate (latitude, but radius in polar) has a minimum of 0
extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
lon_cycle = 360,
lat_cycle = None,
lon_minmax = None,
lat_minmax = (0, np.inf),
)
# Find a grid values appropriate for the coordinate (degree,
# minute, second). The argument is a approximate number of grids.
grid_locator1 = angle_helper.LocatorDMS(12)
# And also uses an appropriate formatter. Note that the acceptable Locator
# and Formatter classes are different than that of Matplotlib's, and you
# cannot directly use Matplotlib's Locator and Formatter here (but may be
# possible in the future).
tick_formatter1 = angle_helper.FormatterDMS()
grid_helper = GridHelperCurveLinear(tr,
extreme_finder=extreme_finder,
grid_locator1=grid_locator1,
tick_formatter1=tick_formatter1
)
from mpl_toolkits.axisartist.grid_helper_curvelinear \
import GridHelperCurveLinear
from mpl_toolkits.axisartist import Axes
# from curved coordinate to rectlinear coordinate.
def tr(x, y):
x, y = np.asarray(x), np.asarray(y)
return x, y-x
# from rectlinear coordinate to curved coordinate.
def inv_tr(x, y):
x, y = np.asarray(x), np.asarray(y)
return x, y+x
grid_helper = GridHelperCurveLinear((tr, inv_tr))
fig.add_subplot(axes_class=Axes, grid_helper=grid_helper)
ax1 = SubplotHost(fig, 1, 2, 2, grid_helper=grid_helper)
# A parasite axes with given transform
ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
# note that ax2.transData == tr + ax1.transData
# Anything you draw in ax2 will match the ticks and grids of ax1.
ax1.parasites.append(ax2)
ax.axis["bottom"].toggle(ticklabels=False)
Recommend
Matplotlib Overview of axisartist toolkit axisartist
Matplotlib The mplot3d Toolkit Tri-Surface plots
Matplotlib The mplot3d Toolkit
Matplotlib Overview of mpl_toolkits.axes_grid1 AxesDivider
Matplotlib Overview of mpl_toolkits.axes_grid1 axes_grid1 RGBAxes
Matplotlib Overview of mpl_toolkits.axes_grid1 axes_grid1 InsetLocator
Matplotlib Overview of mpl_toolkits.axes_grid1 axes_grid1 ParasiteAxes Example 2. twin
Matplotlib Overview of mpl_toolkits.axes_grid1 axes_grid1 AxesDivider Class
Matplotlib Image tutorial Plotting numpy arrays as images Array Interpolation schemes
Matplotlib Image tutorial Plotting numpy arrays as images Examining a specific data range
Matplotlib Image tutorial Plotting numpy arrays as images Color scale reference
Matplotlib Image tutorial Plotting numpy arrays as images
Matplotlib Image tutorial Importing image data into Numpy arrays
Matplotlib Image tutorial Startup commands
Matplotlib Pyplot tutorial Logarithmic and other nonlinear axes
Matplotlib Pyplot tutorial Working with text Annotating text
Matplotlib Pyplot tutorial Working with text Using mathematical expressions in text
Matplotlib Pyplot tutorial Working with text
Matplotlib Pyplot tutorial Working with multiple figures and axes
Matplotlib Pyplot tutorial Controlling line properties
Matplotlib Pyplot tutorial Plotting with categorical variables
Matplotlib Pyplot tutorial Plotting with keyword strings
Matplotlib Pyplot tutorial Intro to pyplot Formatting the style of your plot
Matplotlib Pyplot tutorial Intro to pyplot
Matplotlib Basic Usage Working with multiple Figures and Axes
Matplotlib Basic Usage Color mapped data
Matplotlib Basic Usage Axis scales and ticks Additional Axis objects
Matplotlib Basic Usage Axis scales and ticks Plotting dates and strings
Matplotlib Basic Usage Axis scales and ticks Tick locators and formatters
Matplotlib Basic Usage Axis scales and ticks Scales
Matplotlib Basic Usage Labelling plots Legends
Matplotlib Basic Usage Labelling plots Annotations
Matplotlib Basic Usage Labelling plots Using mathematical expressions in text
Matplotlib Basic Usage Labelling plots Axes labels and text
Matplotlib Basic Usage Styling Artists Linewidths, linestyles, and markersizes
Matplotlib Basic Usage Styling Artists Colors
Matplotlib Basic Usage Styling Artists
Matplotlib Basic Usage Coding styles Making a helper functions
Matplotlib Basic Usage Coding styles The object-oriented and the pyplot interfaces
Matplotlib Basic Usage Types of inputs to plotting functions
Matplotlib Basic Usage Parts of a Figure Figure
Matplotlib Basic Usage A simple example
Matplotlib The Lifecycle of a Plot Saving our plot
Matplotlib The Lifecycle of a Plot Combining multiple visualizations
Matplotlib The Lifecycle of a Plot Customizing the plot
Matplotlib The Lifecycle of a Plot Controlling the style
Matplotlib The Lifecycle of a Plot Getting started
Matplotlib The Lifecycle of a Plot Our data
Customizing Matplotlib with style sheets and rcParams The matplotlibrc file
Customizing Matplotlib with style sheets and rcParams Using style sheets Temporary styling
Customizing Matplotlib with style sheets and rcParams Using style sheets Composing styles
Customizing Matplotlib with style sheets and rcParams Using style sheets Defining your own style
Customizing Matplotlib with style sheets and rcParams Using style sheets