Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tap-plot #5

Closed
stoeckel4code opened this issue Feb 24, 2020 · 20 comments
Closed

Tap-plot #5

stoeckel4code opened this issue Feb 24, 2020 · 20 comments

Comments

@stoeckel4code
Copy link
Collaborator

I made a first attempt to run the tap-plot (tap). Shall I go on with styling, adding p-values, adding meanplots etc, or shall I try something different? It seems that all the build-in funktions of Holoviews are not for higher dimensional data. My idea would be, to use an input-function, which asks to choose a dimension and only then calculate the plot.

@kuchaale
Copy link
Member

Does it work or do you have only issues with the styling? Does the tap plot work also with hvplot.quadmesh as you implemented before?

@stoeckel4code
Copy link
Collaborator Author

Does it work or do you have only issues with the styling?

It works fine.

Does the tap plot work also with hvplot.quadmesh as you implemented before?

I think it would work for some fixed dimensions

@stoeckel4code
Copy link
Collaborator Author

stoeckel4code commented Feb 25, 2020

I tried the quadmesh, but it doesn't work. It works for an initial coordinate, but the streams function doesn't accept any further values.
My second attempt was replacing the roi-funtion with the tap-function This works only for the heatmap, but the heatmap made some problems with the p-values (countours).

@kuchaale
Copy link
Member

I see that heatmap cannot be overplot with contours. Thus I would stick with quadmesh unless we find another option how to plot the statistical significance. Therefore we need to find a way how the tap function could work with hvplot.quadmesh.

@kuchaale
Copy link
Member

Here I enclose a inspiration how to handle it. XrViz's dashboard class is great inpiration ;) However, I used this example using panel to implement the tap functionality.

graph_opts = dict(cmap = 'RdBu_r', symmetric=True, logy = True, colorbar = True, \
                width = 400, ylim=(1000,0.1), active_tools=['wheel_zoom', 'pan'])
sel_data = ds_sel
graph = sel_data['coefs'].hvplot.quadmesh(x = 'x', y = 'y').opts(**graph_opts)


points = graph#hv.Points([])
taps = []
stream = hv.streams.Tap(source=points, x=np.nan, y=np.nan)

tap_stream = hv.streams.Tap(transient=True)
tap_stream.source = graph
taps_graph = hv.DynamicMap(
                create_taps_graph,
                streams=[tap_stream])


def create_taps_graph(x, y):
    """
    from: https://github.com/intake/xrviz/blob/master/xrviz/dashboard.py#L369
    """
    colors = ['#60fffc', '#6da252', '#ff60d4', '#ff9400', '#f4e322',
                  '#229cf4', '#af9862', '#629baf', '#7eed5a', '#e29ec8',
                  '#ff4300']
    color_pool = cycle(colors)
    color = next(iter(color_pool))
    print(color)
    if None not in [x, y]:
        taps.append((x, y, color))

    tapped_map = hv.Points(taps, vdims=['z'])
    tapped_map.opts(color='z', marker='triangle', line_color='black',
                    size=8)

    return tapped_map

@pn.depends(stream.param.x, stream.param.y)
def location(x, y):
    """
    from: https://discourse.holoviz.org/t/example-of-using-holoviews-tapstream-with-panel/166/3
    """
    first_column = pn.pane.Str(f'Click at {x:.2f}, {y:.2f}')
    if np.nan not in [x,y]:
        temp = sel_data.sel(x=x,y=y, method = 'nearest')
        temp2 = temp['coefs'].where(temp['p_values'] < 0.05) # mark stat. sign. values
        second_column = temp['coefs'].hvplot(width = 300) * temp2.hvplot.scatter(c='k')
    else:
        second_column = pn.Spacer(name='Series Graph')
    return pn.Column(first_column, second_column) # hv.Points((x,y)))#

pn.Row(graph*taps_graph, location)

@stoeckel4code
Copy link
Collaborator Author

I tried your example and the string-output works, but not on any plot-function. It seems that the stream function gets interrupted as the dataset is called. However, the ploting works, when no dataset is called (as you can see here in this meaningless function). It follows that not hv.Curve is the problem, but the xr.dateset

@stoeckel4code
Copy link
Collaborator Author

My attempt today was to use numpy arrays in connection with matlab.plot to get a result. It appears, that the plot is computed, but in't shown.

@kuchaale
Copy link
Member

It works in my case (see here). It looks like this
obrazek

@stoeckel4code
Copy link
Collaborator Author

Ok, that solves everything. I will go on and add it to the repository, add the p-values etc..

@stoeckel4code
Copy link
Collaborator Author

here you mark stat, sign. values, so plotting the p values seems needless. Shall I go on editing the tap plot, or isn't this nessesary and I focus on other plots?

@kuchaale
Copy link
Member

kuchaale commented Mar 2, 2020

I think that you have enough references to produce both tap and ROI prototypes in the original scheme. Of course, the best option would be to have one prototype and let a user decide about the selection tool (ROI or tap).

@stoeckel4code
Copy link
Collaborator Author

stoeckel4code commented Mar 6, 2020

This code works for one variable but not more. I dont find the problem. Always when I delete one of the selected variables the tapplot doesn't work.

@kuchaale
Copy link
Member

What is actually progress here? Do you need any feedback from me?

@stoeckel4code
Copy link
Collaborator Author

now, It works for any number of variables. My current problem is, that I need Slider for the Quadmesh and the Tapplot and can't combine them to one.

@stoeckel4code
Copy link
Collaborator Author

I added widgets to control the parameters on the Tap-plot (here). I will go on with styling the plot and adding a table showing the clicked x , y values. Which improvment you think should I add?

@kuchaale
Copy link
Member

I like the progress. Nevertheless, I think that the issue with 2 sliders needs to be solved. I leave the styling up to you. It would be nice to plot several line plots together. Currently, we can see only tapped points on the left but only one line on the right.

@stoeckel4code
Copy link
Collaborator Author

The issue with the 2 sliders was solved by changing the value directly in the function (here).

@kuchaale
Copy link
Member

kuchaale commented Apr 1, 2020

Are there any issues blocking adding the following?

  • p-value contours to the quadmesh
  • more variables for selection (ozone, temperature etc.)
  • plotting several tapped lines together

If yes, please open separate issues and close this one. You can still work on it (out of the contract) and/or it will be logged for the future reference. Ok?

@stoeckel4code
Copy link
Collaborator Author

  • p-value contours to the quadmesh

for some reason, it doesn't work as intended. I try some further aproaches.

  • more variables for selection (ozone, temperature etc.)

done.

  • plotting several tapped lines together

I currently work on it.

@kuchaale
Copy link
Member

kuchaale commented Apr 9, 2020

#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants