question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discrepancy between image from hv and using Datashader directly

See original GitHub issue

screen shot 2018-07-24 at 9 09 29 am

On the left is the saved image from datashader, on the right is the layout / plot from holoviews, datashader, and bokeh. The only difference that I’ve been able to discern between my two methods is that I’m using the line method to plot with datashader and the curve method with holoviews: left:

    for column in range(1,4):
        agg = cvs.line(df, '0', str(column), ds.count())
        img = tf.shade(agg, how='eq_hist')
        imgs.append(img)

    stacked = tf.stack(*imgs)
    export_image(stacked, data)

right:

    curvesx = hv.Curve(df.iloc[:, [0,1]])
    curvesy = hv.Curve(df.iloc[:, [0,2]])
    curvesz = hv.Curve(df.iloc[:, [0,3]])
    layout = curvesx * curvesy * curvesz
    renderer = hv.renderer('bokeh').instance(fig='html')
    plot = renderer.get_plot(datashade(layout, dynamic = False)).state
    plot.plot_width = 800
    plot.plot_height = 500
    show(plot)

Not only does the data look a little different, (note the bottom of the graph, on the left there is data that is an outlier which doesn’t exist on the right). I’ve tried different aspect ratios, sizes etc.

In addition, I believe that I’m not generating a large enough image from holoviews, the right side graph seems much lower quality then the saved image, almost as if it is created small and then stretched out.

Any insight?

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jbednarcommented, Jul 24, 2018

Maybe you want something like this?

import pandas as pd, numpy as np
df = pd.DataFrame([[1, 10, 100], [2, 20, 200]],
                   columns=['0', '1', '2'])
df
screen shot 2018-07-24 at 6 12 05 pm
def concat_columns(df, separator=np.NaN):
    x = df.columns[0]
    df = df.append({x:separator}, ignore_index=True)
    return pd.concat([df[[x,c]].rename(columns={x:'x', c:'y'}) for c in df.columns[1:]])

df2 = concat_columns(df)
df2
screen shot 2018-07-24 at 6 12 31 pm

You should then be able to datashade df2 directly.

0reactions
adamhrosenbergcommented, Jul 25, 2018

I’ll look into it thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discrepancy between image from hv and using Datashader ...
I believe the HoloViews interface is concatenating all curves (separated by NaNs) and aggregating that entire collection of curves, correctly ...
Read more >
Plotting Pitfalls — Datashader v0.14.3
Common plotting pitfalls that get worse with large data# · Overplotting · Oversaturation · Undersampling · Undersaturation · Underutilized range · Nonuniform ...
Read more >
pyviz/pyviz - Gitter
There seems to be a mismatch between the resolution that datashader is targeting and the resolution of the image. bokeh_plot (14).png.
Read more >
Using holoviews renderer with datashader in a script
import holoviews as hv import numpy as np from holoviews.operation.datashader import datashade, dynspread hv.extension('bokeh') #### Disable ...
Read more >
Working with large data using datashader — HoloViews v1.15.3
import datashader as ds import numpy as np import holoviews as hv import ... Because all of the data in these plots gets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found