We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates


Previous topic

axes_grid example code: simple_axesgrid2.py

Next topic

color Examples

This Page

axes_grid example code: simple_axisline4.pyΒΆ

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

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import numpy as np

ax = host_subplot(111, axes_class=AA.Axes)
xx = np.arange(0, 2*np.pi, 0.01)
ax.plot(xx, np.sin(xx))

ax2 = ax.twin() # ax2 is responsible for "top" axis and "right" axis
ax2.set_xticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
ax2.set_xticklabels(["$0$", r"$\frac{1}{2}\pi$",
                     r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])



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