Closed jobh closed 1 year ago
Thanks for the report @jobh.
Antialiasing doesn't currently work using the Pipeline
approach as there is extra antialiasing information that doesn't get through to the low-level calculation functions this way. It can be fixed though.
Is there a particular reason that you are using the Pipeline
approach? This equivalent code using Canvas.line
works fine:
import datashader as ds
import pandas as pd
df = pd.DataFrame(dict(x=[0,1],y=[0,1]))
cvs = ds.Canvas(plot_width=400, plot_height=400)
agg = cvs.line(source=df, x='x', y='y', line_width=1)
im = ds.transfer_functions.shade(agg)
Thanks @ianthomas23.
What I have is basically a dynamic map-tile server using datashader. The pipeline API is "just right" for this: Data is parsed once, up-front, while images are generated on-the fly based on viewport (location+size).
The Canvas
approach — I'm not too familiar with it, but specifying the size (and maybe location?) before adding data is probably not performant enough.
Edit: ...but actually timing it on [1k lines of 10k points each] indicates I'm wrong about that... don't know if that is expected.
Btw; I'm not too worried about the anti-aliasing, only the line width. If that makes a difference.
The Pipeline
approach is really just a thin wrapper around the Canvas
approach:
https://github.com/holoviz/datashader/blob/f7de27162a6b06216599ddbb197a89215bc8478f/datashader/pipeline.py#L66-L71
You might be saving some time by using a specific Glyph
object rather than letting Canvas.line
work it out, but this should negligible compared to the computation time.
Nowadays a line_width
other than zero implies antialiasing. If you are happy without antialiasing then you can leave line_width
at its default of 0
and it will definitely run faster.
Regardless, this bug is quite simple to fix so it should be in the next release, possibly in the next couple of weeks.
I will probably switch to Canvas
as you suggest, but thanks for fixing anyway :-)
ALL software version info
datashader version 0.14.4
Description of expected behavior and the observed behavior
When setting non-zero line_width on
LineAxis0
glyphs (passed toPipeline
), an error is raised. Withset_line_width(0)
, or not callingset_line_width
at all, it works fine.In earlier versions (0.14.2 I think)
line_width>0
did not produce an error. However, it did not work correctly either (line width was respected but constant color/not shaded), which was why I tried to upgrade.Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
The stack is shown below, but the relevant bit seems to be:
Full trace: