Reputation: 113
here is my code:
import holoviews as hv
import datashader as ds
import dask.dataframe as dd
import geoviews as gv
from cartopy import crs
from holoviews.operation.datashader import datashade
hv.extension('bokeh', width=95)
%opts RGB [width=1200 height=682 xaxis=None yaxis=None show_grid=False bgcolor='black']
%opts Shape (fill_alpha=0 line_width=1.5) [apply_ranges=False tools=['tap']]
%opts Points [apply_ranges=False ] WMTS (alpha=0.5)
color_key = {worda:'red', wordb:'green'}
races = {worda:worda, wordb:wordb}
color_points = hv.NdOverlay({races[k]: gv.Points([0,0], crs=crs.PlateCarree())(style=dict(color=v))
for k, v in color_key.items()})
census_points = hv.Points(df, kdims=['x', 'y'], vdims=['word'])
x_range, y_range = ((-13884029.0, -7453303.5), (2818291.5, 6335972.0)) # Continental USA
shade_defaults = dict(x_range=x_range, y_range=y_range, x_sampling=10, y_sampling=10, width=1200, height=682,
color_key=color_key, aggregator=ds.count_cat('word'),)
shaded = datashade(census_points, **shade_defaults)
shaded()
and the result looks like: enter image description here but I want the size of points more bigger, like this: enter image description here
How can I change my code for my goal? Thanks!
Upvotes: 1
Views: 3055
Reputation: 12818
As answered by James A. Bednar, using dynspread() works to make points in your datashaded scatter plot larger.
Your code should look like this:
from holoviews.operation.datashader import datashade, dynspread
dynspread(datashade(your_holoviews_scatterplot))
This makes sure that points in your datashaded scatterplot take up more pixels on your screen.
dynspread() has some parameters to influence the size of the markers, see also:
Documentation on dynspread()
You could for example change the threshold parameter to get even larger markers, although it doesn't make the plot prettier. Threshold can hold values between 0 and 1. Threshold is a tuning parameter, with higher values giving more spreading.
dynspread(datashade(your_holoviews_scatterplot), threshold=1.0)
Upvotes: 2
Reputation: 3255
(Copied from the parallel Github issue https://github.com/ioam/holoviews/issues/2877#issuecomment-405158027.)
So far, datashader only includes infinitely small points and infinitely thin lines, which would be invisible if not for the non-zero width of a pixel in the image. Adding the ability of a point or line to have an extent is something we plan to add eventually, but for now, you have a couple of options:
Upvotes: 1