holoviz / holoviews

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

Documentation: tuples vs lists #4633

Open neighthan opened 4 years ago

neighthan commented 4 years ago

Issue: different behavior for lists vs tuples

I've been confused multiple times because of how holoviews handles tuples vs lists. Here are a couple of examples:

# imports / dummy data
import numpy as np
import holoviews as hv
hv.extension("bokeh")

x = np.arange(10)
y = 2 * x + 3
c = np.linspace(0, 1, len(x))

As input data to a plot

hv.Scatter((x, y, c))
hv.Scatter([x, y, c])

For vdims

So, I've learned that, for how I format my data, I should use tuples instead of lists. Then I try to rename my vdims:

hv.Scatter((x, y, c), kdims="h", vdims=("w", "c"))
hv.Scatter((x, y, c), kdims="h", vdims=["w", "c"])

Solution: documentation?

For me, it'd be nice if, e.g., hv.Scatter((x, y)) and hv.Scatter([x, y]) were equivalent, but I assume some other people are depending on the current behavior of [x, y], so this is just a request for clearer documentation. I don't know where would be the best place to put that information, though (the FAQ? unless I'm the only one for whom this issue is "frequent" enough). This information is probably already available somewhere, but I'm not sure how I'd easily find it when, e.g., I don't understand why my vdims aren't working how I expect..

neighthan commented 4 years ago

Ah, the FAQ does address what tuples in vdims are used for; I didn't see it since I was searching for the word vdims. If one was passing in a dataframe, then a tuple of (column_name, plot_axis_name) could be given.

jlstevens commented 4 years ago

Thanks for reporting this. Maybe we should add the word vdims to the FAQ so this behavior is more searchable..