discontinous axis in subplot - python matplotlib
Question: I would like to have plot with an y axis that is devided into two parts. The
lower part should have a normal scale while the upper one should scale with a
factor of 10.

I already found some examples on how to make plots with broken x or y axes,
for example: <http://matplotlib.org/examples/pylab_examples/broken_axis.html>

But I do not understand how to achieve this, when I want to apply this to one
single subplot inside a 2x2 grid of plots. If it is important, I set up the
plots like this:

    
    
    fig = plt.figure()
    fig.set_size_inches(8, 6)
    
    fig.add_subplot(221)
    [...]
    fig.add_subplot(222)
    [...]
    


Answer: Couldn't you set up a 4x4 grid of axes, and have 3 of the axes span 2x2 of
that space? Then the plot you want to have broken axes on can just cover the
remaining 2x2 space as parts `ax4_upper` and `ax4_lower`.

    
    
    ax1 = plt.subplot2grid((4, 4), (0, 0), colspan=2, rowspan=2)
    ax2 = plt.subplot2grid((4, 4), (0, 2), colspan=2, rowspan=2)
    ax3 = plt.subplot2grid((4, 4), (2, 0), colspan=2, rowspan=2)
    ax4_upper = plt.subplot2grid((4, 4), (2, 2), colspan=2, rowspan=1)
    ax4_lower = plt.subplot2grid((4, 4), (3, 2), colspan=2, rowspan=1)
    

You can then set the `ylim` values for `ax4_upper` and `ax4_lower`, and
continue as your example showed:

    
    
    # hide the spines between ax4 upper and lower
    ax4_upper.spines['bottom'].set_visible(False)
    ax4_lower.spines['top'].set_visible(False)
    ax4_upper.xaxis.tick_top()
    ax4_upper.tick_params(labeltop='off') # don't put tick labels at the top
    ax4_lower.xaxis.tick_bottom()
    
    d = .015 # how big to make the diagonal lines in axes coordinates
    # arguments to pass plot, just so we don't keep repeating them
    kwargs = dict(transform=ax4_upper.transAxes, color='k', clip_on=False)
    ax4_upper.plot((-d,+d),(-d,+d), **kwargs)      # top-left diagonal
    ax4_upper.plot((1-d,1+d),(-d,+d), **kwargs)    # top-right diagonal
    
    kwargs.update(transform=ax4_lower.transAxes)  # switch to the bottom axes
    ax4_lower.plot((-d,+d),(1-d,1+d), **kwargs)   # bottom-left diagonal
    ax4_lower.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-right diagonal
    
    plt.show()
    

![2x2 with broken axes](http://i.stack.imgur.com/ylukO.png)

