You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Point sizes disagree between matplotlib and datashader #315
For plotting points with matplotlib, we use the s argument of scatter(). The square root of s specifies the width and height of the markers in points.
In the datashader approach, we use ds.tf.spread(agg, px=px) to regulate the size of the markers. Here, px is calculated like this: px = int(np.round(np.sqrt(render_params.size))), to make the behavior agree to the matplotlib approach.
Problem: If you alter the dpi in pl.show(), the point size of the datashader points remains the same, whileit changes for matplotlib, leading to different sizes:
Now it looks like this, for dpi [50, 100, 200, 300] using blob.pl.render_points(element="blobs_points", size=400, color="blue").pl.render_points(element="blobs_points", size=400, color="yellow", method="datashader", alpha=1).pl.show(dpi=100)
Should be correct imo
Activity
Sonja-Stockhaus commentedon Jul 31, 2024
Btw I think for
dpi=100, the mpl points are slightly larger than the ds points because marker edges are drawn (default linewidth = 1.5), see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html.However, this is not the actual problem
Sonja-Stockhaus commentedon Jul 31, 2024
Solution for now: use
dpi/100as a factor to adaptpxto varyingdpiSonja-Stockhaus commentedon Aug 6, 2024
Now it looks like this, for dpi
[50, 100, 200, 300]usingblob.pl.render_points(element="blobs_points", size=400, color="blue").pl.render_points(element="blobs_points", size=400, color="yellow", method="datashader", alpha=1).pl.show(dpi=100)Should be correct imo
(matplotlib points bluse, datashader yellow)




LucaMarconato commentedon Aug 6, 2024
Looks good to me. The tiny pixel offset is probably inevitable and acceptable.