Xlim of individual plots ignored in layout

I’ve been unable to get xlim to work on multiple hist plots when combined in a layout.

As a basic example, the following code demonstrats this.

The xlim are respected in the individual hist plots as expected (if displayed) but not in P1.

import hvplot.pandas 

from bokeh.sampledata.autompg import autompg_clean

autompg_clean.sample(n=5)

h1= autompg_clean.hvplot.hist("weight")

h1.opts(xlim=(2500,4000))

h2= autompg_clean.hvplot.hist("weight")

h2.opts(xlim=(1500,3000))

P1= h1 + h2

P1.cols(1)

Thus, my histograms have misaligned zero lines for different datasets compared.

I’ve had no better luck setting bin_range in the separate hist calls either.

Thanks for any help!

Hi @deusirae,

This works as far as I can tell


from bokeh.sampledata.autompg import autompg_clean

autompg_clean.sample(n=5)

print(autompg_clean)

h1= autompg_clean.hvplot.hist("weight")

h1.opts(xlim=(2500,5000))

h2= autompg_clean.hvplot.hist("hp")

h2.opts(xlim=(10,200))

P1= h1 + h2

P1.cols(1)

My feeling is because using weight from the same dataset in the example you have it is taking the minimum and maximum limiter from h1 and h2 for p1, that’s what I’m seeing when I run it. I don’t know if there is a way to alter the behavior in code or whether you should just name the x differently

Thanks. That example also works for me. Your suggestion has some logic however in my actual code I’m already using two different datasets plotting two different parameters with differently named ‘x’ and unfortunately it doesn’t use the xlim information in the combined plot. It seems to default to the maximum range for each dataset automatically.

However, if I place the hist into a list and use

P1= hv.Overlay(list_of_hist)

the xlim of the histograms are respected.