holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.7k stars 403 forks source link

Support multi-axis overlay in x-direction #5855

Open GeoVizNow opened 1 year ago

GeoVizNow commented 1 year ago

Thanks for making overlays with multiple y-axes become a possibility in holoviews! Amazing work and really helping. I was trying it out for 'holoviews.Curve' and see that it is very useful. It works really well when laying the kdim out horizontally. But in situations where the independent dimension is to be laid out vertically, e.g. wellbore data where depth is often expressed vertically, it does however not seem to work correctly when using the option 'invert_axes=True' to flip the vertical and horizontal axes.

ALL software version info

os: windows 10 enterprise ide: Jupyter notebook holoviews: version: 1.17.1 bokeh: version: 3.2.1

Description of expected behavior and the observed behavior

When swapping the axes using 'invert_axes=True' then the expectation is that what was multiple y-axes, becomes multiple x-axes, but still referring to vdims.

Complete, minimal, self-contained example code that reproduces the issue

# In a jupyter notebook:
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

# Prep data
zs = [500, 1000, 1500, 2000, 2500, 3000]

y1 = [7, 1, 8, 7, 9, 11]
y2 = [5, 2, 2, 5, 7, 11]
y3 = [3, 4, 4, 3, 9, 11]

# Make overlay
overlay = hv.Overlay([
    hv.Curve((zs, y1), kdims='depth (kdim)', vdims='sl', label='s1').opts(ylim=(-2, 12), tools=['hover'], yaxis='right'),
    hv.Curve((zs, y2), kdims='depth (kdim)', vdims='s2', label='s2').opts(ylim=(11,- 3), tools=['hover']),  # , yaxis='right', toolbar='left'),
    hv.Curve((zs, y3), kdims='depth (kdim)', vdims='s3', label='s3').opts(tools=['hover'])
])

# Refer displayable overlay
overlay.opts(opts.Curve(multi_y=True, invert_xaxis=True, invert_axes=False), opts.Overlay(multi_y=True, frame_width=850, frame_height=250))

Produces: image

Modifying the code with 'invert_axes=True' produces:

overlay.opts(opts.Curve(multi_y=True, invert_xaxis=True, invert_axes=True), opts.Overlay(multi_y=True, frame_width=850, frame_height=250))

image

GeoVizNow commented 1 year ago

Edited post: For the second chart where I want to lay out the kdim vertically the below example better illustrates what happens:

overlay_vertical = hv.Overlay([
    hv.Curve((zs, y1), kdims='depth (kdim)', vdims='sl', label='s1').opts(ylim=(-2, 12), tools=['hover'], yaxis='right'),
    hv.Curve((zs, y2), kdims='depth (kdim)', vdims='s2', label='s2').opts(ylim=(11,- 3), tools=['hover']),  # , yaxis='right', toolbar='left'),
    hv.Curve((zs, y3), kdims='depth (kdim)', vdims='s3', label='s3').opts(tools=['hover'])
])

overlay_vertical.opts(opts.Curve(multi_y=True, invert_xaxis=True, invert_axes=True), opts.Overlay(multi_y=True, frame_width=250, frame_height=850))

The following are changed compared to the figure where kdim is laid out horizontally:

image

It seems not all components are set up for swapping axes yet. I was kind of expecting 'multi_y' to mean multiple vdim axes, but maybe this is not what is intended. Also I am often confused about ylim and xlim. Is it the ylim before invert_axes that is used (which I think it is)?

GeoVizNow commented 1 year ago

I wonder if I am missing something or if this is a bug.

hoxbro commented 1 year ago

multi-axis has not been implemented for the x-axis, which is why you are seeing this weird behavior.

GeoVizNow commented 1 year ago

Thanks @Hoxbro, then I do understand. I would have loved it if this may some time becomes implemented for multiple x-axes. Not sure how far away though in time or complexity. For data such as log curve data in drilled wells it is very common to have several x-axes and to have one or more depth dimension(s) as y-axis. Also it is common to fill between two curves or between a curve and a constant. But the kdim is typically the y-axis reversed. The multi_y is anyways proving very useful already.

GeoVizNow commented 1 year ago

Should I close this one then?

hoxbro commented 1 year ago

I think we should repurpose this issue or create a new one about adding support for multi-axis in the x-direction.

GeoVizNow commented 1 year ago

@Hoxbro, please feel free to repurpose the issue if you can.