Download notebook (.ipynb)

Sharing X,Y-axis Scale Limits#

Use sharex, sharey parameters in the gggrid() function to control sharing of axis scale limits among plots in grid:

  • “all” or True - share limits between all subplots

  • “none” or False - do not share limits between subplots

  • “row” - share limits between subplots in the same row

  • “col” - share limits between subplots in the same column

from lets_plot import *

import numpy as np
LetsPlot.setup_html()
np.random.seed(37)
dat1 = {'x': np.random.normal(size=1000)}
dat2 = {'x': np.random.normal(size=200)}

p1 = ggplot(dat1, aes(x='x')) + geom_histogram()
p2 = ggplot(dat2, aes(x='x')) + geom_histogram()

1. Two Independent Charts in Grid#

gggrid([p1, p2])

2. Share Scale Limits of the Y-axis#

gggrid([p1, p2], sharey=True)

3. Share Scale Limits of both, X and Y-axis#

gggrid([p1, p2], sharex=True, sharey=True)