holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

Using the invert_yaxis option with adjoint layouts

Open jlstevens opened this issue 7 years ago • 1 comments

This issues continues from #2276 after commenting out the sampling exception described in that issue.

This much is the same as before:

import time
import datetime
import numpy as np
import xarray as xr
import holoviews as hv
from holoviews.operation.datashader import regrid
hv.extension('bokeh')

interval = 70
now = datetime.datetime.now()
timedelta = datetime.timedelta(seconds=interval)
time = [now + (i * timedelta) for i in range(50)]
xvals = np.linspace(1,10, 50)
vals = np.random.rand(50,50)
arr = xr.DataArray(vals, coords={'time': time, 'xvals': xvals},
                   dims=['xvals', 'time'])

image = hv.Image(arr, ['time', 'xvals'])  # This displays fine
regridded = regrid(image,  aggregator='mean')

Now I add a curve cross-section and some options:

curve = image.reduce(dimensions=['time'], function=np.mean)
opts = {'Image':{'plot':{'invert_yaxis':True}},
        'HLine':{'style':dict(color='black', line_dash='dashed')}}

This works as expected:

image

But applying the options:

image

Zooming out a bit:

image

This is obviously quite wrong and due to invert_yzaxis on the Image but not the Curve. Setting this option on the Curve results in the correct result:

image

I think this issue is down to option propagation when using adjoint layouts.

Anyway, I was doing all this to try to reproduce another bug where regrid was complaining about negative dimensions (using the components given in this example) but although I managed to reproduce it once or twice, I am yet to nail down the exact steps that cause this problem.

jlstevens avatar Jan 28 '18 22:01 jlstevens

I have the same issue when working with Image stacks. Using inverted y-axis (maybe because of a wrong understanding of hv.Image), gives a similar issue upon transform or collapse:

import numpy as np
import holoviews as hv

def get_image():
    return hv.Image(np.random.randint(0, 255, size=(30, 20)), bounds=(0,0,30,20)).opts(invert_yaxis=True)
stack = hv.HoloMap({i: get_image() for i in range(10)}, kdims=['snap'])
stack + stack.collapse(['snap'], np.mean)#.opts(invert_yaxis=True)  # <-- this corrects the view

image

holoviews 1.14.9

rhambach avatar Jul 28 '22 22:07 rhambach