Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error in subplots sharey docs? #3145

Closed
Closed
@fardal

Description

@fardal

I'm using matplotlib version 1.3.1. I think sharey description is incorrect,
as might be guessed from swapping x-y, row-col.
http://matplotlib.org/api/pyplot_api.html?highlight=subplots#matplotlib.pyplot.subplots

Call this function with argument 'row' or 'col'.

def testdocs(setting):
    wavelength = np.array([0,2,4,6,8,10])
    flux = np.array([3.,1.5,0.5,1,2,2.5])

    #text from docs
    if (setting=='row'):
        print "each subplot row will share a Y axis."
    elif (setting=='col'):
        print """each subplot column will share a Y axis and the y tick labels 
on all but the last row will have visible set to False."""
    else:
        return

    sharex = False
    sharey = setting

    nrow = 2
    ncol = 3
    fig, axlist = plt.subplots(nrow, ncol, sharex=sharex, sharey=sharey)
    length = len(wavelength)
    for i, axrow in enumerate(axlist):
        for j, axes in enumerate(axrow):
            if (setting=='row'):
                axes.plot(wavelength*(i+1), flux*(j+1))
            else:
                axes.plot(wavelength*(j+1), flux*(i+j+1))

    xtitle = 'foo'
    ytitle = 'bar'
    fig.text(0.5, 0.04, xtitle, ha='center', va='center')
    fig.text(0.06, 0.5, ytitle, ha='center', va='center', rotation='vertical')
    plt.show()

TAC : edited to fix formatting

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions