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 Issues from a Learner's Perspective #2116

Open mforbes opened 7 years ago

mforbes commented 7 years ago

As I am starting again to seriously consider using HoloViews, I come across deficiencies in the documentation from the perspective of a learner. I will collect these here:

Curve.html

mforbes commented 7 years ago

Visualization Options

I have learned that the list of options can be seen by using hv.help() or %%output info=True as specified in the FAQ, and that I can find out the visualization parameters by hv.help(visualization=True) (though for the life of me, I cannot see where I did learn this! I would have expected in Customizing_Plots.html or Customization.html but it does not seem to be there.) However, it is still quite a mystery to me how to actually set options.

Here is how I (failed) to figure things out. For example: suppose I want to change the height of the following plots:

x = np.linspace(0,1,100)
l = hv.Curve((x, x**2)) + hv.Curve((x, np.sin(x)))
l

First I need to know to do

>>> hv.help(l, visualization=True)
...
Target Specifications
...
Element: Curve.Curve
Container: Layout.Layout
...
To see the options info for one of these target specifications,
which are of the form {type}[.{group}[.{label}]], do holoviews.help({type}).  

Parameters of 'LayoutPlot'
==========================
...
Name                            Value                    Type       Bounds    Mode  
...
height                           300                   Integer                V RW  

My reading of this documentation is that something called LayoutPlot has a height parameter that I can customize. I also have no idea what the "{type}[.{group}[.{label}]], do holoviews.help({type})" construct means. The only thing in the documentation called "Type" is "Integer". Nothing is called a "type", "group", or "label".

Failures:

hv.help('LayoutPlot')     # no Python documentation found for 'LayoutPlot'
l.height = 100            # Silently fails to do anything.  Okay, this is python.
l.set_param(height=100)   # ValueError: 'height' is not a parameter of Layout10599
l.get_param_values()      # Ah, height is not a parameter... okay
l.opts(height=100)        # TypeError: 'int' object is not iterable??
l.opts(options=dict(height=100)) # AttributeError: 'int' object has no attribute 'items'???

# I give up for now... Let's go to options.
%%opts LayoutPlot [height=100] # WARNING: Unknown elements LayoutPlot not registered with any of the loaded backends.
%%opts Layout [height=100]  # Silently has no effect.
%%opts Curve (height=100)  # Unexpected style option 'height' for Curve... Clear
%%opts Curve [height=100]  # Works!

# Reads Dictionary format section of Customizing Plots
dict_spec = {'Layout.Curve': {'plot': dict(height=100)}}
dict_spec = {'Curve': {'plot': dict(height=100)}}
l.opts(dict_spec)
l   # Does nothing.

Successes:

%%opts Curve [height=100]  # Works!
dict_spec = {'Curve': {'plot': dict(height=100)}}
l.opts(dict_spec)   # This returns a clone that has the options set.
dict_spec = {'Curve': {'plot': dict(height=100)}}
hv.opts(dict_spec)   # Globally sets the options

It really surprised me that l.opts(dict_spec) modifies neither the previously displayed layout l or a subsequently displayed l, but returns a clone of the layout that is modified. From the documentation of opts() this is clear in hindsight, but I still have no idea how to programatically set the hight of the actual l layout I have already created, nor why I cannot set the height of the Layout instead of having to work with the individual Curve objects, though I suppose that the Layout probably encapsulates whatever height is needed. It would be extremely helpful if the generated documentation could somehow say that I need to modify the heights of the Curves rather than the Layout (and I do not know what use the height parameter of the Layout is then... can I view it or something?)

mforbes commented 7 years ago

Normalization

For example, I expected the following with distinct Dimensions to not link the axes, but they were linked because they have the same textual name (I think).

x = np.linspace(0,1,100)
x1 = hv.Dimension('x')
x2 = hv.Dimension('x')
(hv.Curve((x, x**2), kdims=[x1], vdims=['t'])
 + hv.Curve((x, np.sin(x)), kdims=[x2], vdims=['z']))