0

I am creating a visualization application with holoviews and panelenter image description here

As one can see, the line is touching all the points which are not what curve should do. It should only show the curve or border like an area chart without color.

I am building this visualization from the example provided here

columns = sorted(data.columns)
discrete = [x for x in columns if data[x].dtype == object or len(data[x].unique()) < 6]
quantileable = [x for x in columns if x not in discrete or  data[x].dtype == '<M8[ns]']

x = pnw.Select(name='X-Axis', value='date', options=quantileable)
y = pnw.Select(name='Y-Axis', value='height_g', options=quantileable)
size = pnw.Select(name='Size', value='None', options=['None'] + quantileable)
@pn.depends(x.param.value, y.param.value, size.param.value) 
def create_figure(x, y, size):
   if size != 'None':
            opts['size'] = hv.dim(size).norm()*5
   return hv.Curve(data, [x, y], label="%s vs %s" % (x.title(), y.title()))

widgets = pn.WidgetBox(x, y, size, width=200)
pn.Row(widgets, create_figure).servable('Cross-selector')

How can I make it look clutter-free?

user3050590
  • 1,656
  • 4
  • 21
  • 40
  • 1
    Curve will connect each point to its adjacent neighbors, and it looks like in this case your points are not ordered by date (or anything else apparently useful!). Try sorting your data by date first, if you want to plot it by date? – James A. Bednar Jun 10 '20 at 22:18
  • It works, but how can I sort the columns at run time. It is like some event, then when the user clicks "date" at x_axis then sort or second dimension at x_axis then sort. Any idea? – user3050590 Jun 11 '20 at 09:09
  • 1
    Presumably you can sort the data inside `create_figure` before calling hv.Curve... – James A. Bednar Jun 12 '20 at 22:31

1 Answers1

0

I was able to sort this problem by adding more information in the return to the create_figure function. I preferred to use hvplot library that is an extension of the holoviews library.

return data.hvplot.line(x,y).sort().aggregate(function=np.mean)

sort() will actually do the job, further aggregation is depended upon the need of the analysis

user3050590
  • 1,656
  • 4
  • 21
  • 40