These are chat archives for pyviz/pyviz

16th
May 2019
Harman Deep Singh
@hdsingh
May 16 03:16

Hello everyone!
I am Harman Deep Singh, a second year CS student. I have been selected to work on A Next Generation GUI for Visualizing Big Gridded Data in Python project in Google Summer of Code. I am very thankful to ESIP and Google for providing me this valuable opportunity. I am very glad to have @rsignell-usgs and @martindurant as my mentors.

intake/xrviz is the repository for this project which aims to create an Interactive visualisation interface for Xarrays. ESIP_GUI/community - Gitter is dedicated chat for this project.

Since this project is using Pyviz libraries for GUI creation, I would be discussing my issues and findings with you all. This community already helped me a lot in figuring out things initially and getting started. I am really very greatful to you all. Glad to be part of this amazing community!

More information about project can be found in ESIPFed/gsoc#14.

Thanks!

James A. Bednar
@jbednar
May 16 03:18
Welcome, Harman! We're excited about this project, and look forward to working with you!
orkun
@orkun
May 16 07:58

Hi,
I think I am highly confused on using hover-tooltips.
It gives 'Nan'.

def cb_es_buffer0(data):
     print (data)
     hover = HoverTool(tooltips=[ ("ili",@ili)])
     return hv.Points(data, kdims=['lon', 'lat'] , vdims=['adi','ili', 'ivmval', 'tanim', 'yas_2'] ).options(tools=[hover] ,color='black', size= 7 ,fill_alpha = 0.4 ,line_color="gray", marker='o' , scaling_factor=4 )

es_point_dmap = hv.DynamicMap(cb_es_buffer0 ,streams=[es_dfstream] )

What am I doing wrong ?
regards

Philipp Rudiger
@philippjfr
May 16 09:20
Welcome Harman! Very excite about this work as well. Don't hesitate to reach out to me for questions.
Harman Deep Singh
@hdsingh
May 16 10:19
@philippjfr @jbednar Thanks a lot sir!! This is what I like the most about this community. The willingness and eagerness to help each other is absolutely amazing!! I am excited to learn from you all!
ea42gh
@ea42gh
May 16 10:42
@orkun, I think you want ("ili", "@ili"), i.e., a string for the second argument.
from bokeh.models import HoverTool
# Syntax: $. are 'special fields':  $x inserts the x-coordinate
#         @. are fields from the data source:
#            provide an extra column of values and declare its name as a vdim (e.g., use a pd.DataFrame)
#         Can apply formating: see https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html
data  = pd.DataFrame( { 'error': [1.1, 3.2, 5.81234 ], 'state': ['NY', 'NJ', 'PA'], 'stuff': ['a','b','c']} )
hover = HoverTool(tooltips=[("error", "@error{0,0.0000}"),
                            ("state", "@state"),
                            ("stuff", "@stuff"),
                            ('coord','($x,$y{.00})')
                           ])
hv.Scatter( data, kdims='error', vdims=['state', 'stuff']).opts(tools=[hover], size=10).redim.range(error=(0,7))
Bede Constantinides
@bede
May 16 11:15
I'm displaying side by side plots of a network with the same nodes but different edges using hv.Graph.from_networkx(g1, nx.layout.circular_layout). Is it possible to reuse the node positions for the adjacent plots so that they don't jump about? I'm new to hv (and networkx, really). Thanks
James A. Bednar
@jbednar
May 16 11:56
Jacob Barhak
@Jacob-Barhak
May 16 13:30
@jbednar , is there a way to stop datashader from interpolating? I tried using smaller matrices of size 1000x1000 and tried to generate an image of the same size using mean and max in hope to generate the one to one image and the image with mean aggregation is not identical to the image with max aggregation. I assume that datashader projects each matrix element to more than one pixel and this is why this happens. If I switch to holoviews rasterize, I should have the same problem since it calls datashader - is there some parameter I can control the size of the matrix element being projected to the pixel map?
Bede Constantinides
@bede
May 16 13:37
Thanks for the example @jbednar. I'm trying to reimplement it with hv.Graph.from_networkx() instead of hv.Graph() which also accepts a nodes arg, but gives me a KeyError when using a string index (for sinks – should these be integers??). The values of nodes.data and g.nodes.data are the same, so I'm unsure what's up. Does this look right?
nodes = hv.Nodes((x, y, sinks, wards), vdims='sink')
(hv.Graph.from_networkx(g, nx.layout.circular_layout, nodes=nodes)
Philipp Rudiger
@philippjfr
May 16 14:01
@Jacob-Barhak Set dynamic=False I think, by default it will adjust to the size of the plot.
Jacob Barhak
@Jacob-Barhak
May 16 14:19
@philippjfr , do you mean as a parameter for Shade? I am looking at the documentation here an cannot find this keyword. To remind you , my code is :
Philipp Rudiger
@philippjfr
May 16 14:20
As a parameter for rasterize/datashade
Jacob Barhak
@Jacob-Barhak
May 16 14:20
def PlotCluster(PermutedMatrix, OutputFile, How, AggregationMethod, PlotSize):
    "plot the cluster"
    PlotData  = xarray.DataArray(PermutedMatrix[0:PlotSize][0:PlotSize])   
    Shaded = datashader.transfer_functions.shade(datashader.Canvas(plot_height=PlotSize, plot_width=PlotSize).raster(PlotData, agg=AggregationMethod), how=How )
    datashader.utils.export_image(Shaded,OutputFile)
James A. Bednar
@jbednar
May 16 14:21
@Jacob-Barhak , Philipp is talking about the HoloViews support for Datashader, while you're using the native Datashader API.
Jacob Barhak
@Jacob-Barhak
May 16 14:21
Ok, @philippjfr , you mean to use holoviews - I will try this. I was about to go back to PIL. I now have one more thing to try.
Philipp Rudiger
@philippjfr
May 16 14:22
Ah, nevermind, didn't read enough of the context.
Switching to holoviews will not help then.
James A. Bednar
@jbednar
May 16 14:22
@bede , You probably want the layout algorithm information to be part of how the nodes object is constructed, prior to making the graph. But beyond that, I can't help much beyond that, as I haven't actually tried what you are doing, but I do know it should be possible even if it's a bit confusing.
Philipp Rudiger
@philippjfr
May 16 14:24
@bede You might have more luck with https://hvplot.pyviz.org/user_guide/NetworkX.html which maybe provides a more familiar API if you're used to networkx.
Jacob Barhak
@Jacob-Barhak
May 16 14:25
OK @philippjfr - I will try PIL and attempt to figure out what is going on at the pixel level - it may be something else I should be exploring . Thanks for helping .
Bede Constantinides
@bede
May 16 14:28
Thanks again @jbednar.
Ooh @philippjfr that's a tidy API. Beautiful docs too. Will explore, thank you.
Jacob Barhak
@Jacob-Barhak
May 16 16:35

Sorry for bothering you @jbednar and @philippjfr , the issue is in my code and not in datashader - I had a bug with the image I was passing to data shader since I was confusing numpy arrays indexing with other languages and therefore I was seeing artifacts of image manipulation. The correct code is:

def PlotCluster(PermutedMatrix, OutputFile, How, AggregationMethod, PlotSize):
    "plot the cluster"
    PlotData  = xarray.DataArray(PermutedMatrix[0:PlotSize,0:PlotSize])   
    Shaded = datashader.transfer_functions.shade(datashader.Canvas(plot_height=PlotSize, plot_width=PlotSize).raster(PlotData, agg=AggregationMethod), how=How )
    datashader.utils.export_image(Shaded,OutputFile)

This time mean and max have the same effect since I am passing only a matrix of the size of the image. before that I was passing a strip like image that was compressed and therefore max and mean had different interpretations. I can now see what is going on. I think I can explain the phenomena better now visually - yet I want to run some more tests - your holoviews suggestion may be helpful now.

James A. Bednar
@jbednar
May 16 19:58
Sounds good!