Search code examples
holoviews

Markers in Holoviews


The following script produces a nice scatterplot as in the picture below

from holoviews import extension, dim, opts, Scatter
from pandas import read_csv
extension('bokeh')
url = 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv'
df = read_csv(url)
scatterplot = Scatter(df, 'flipper_length_mm', ['body_mass_g','island'] )
scatterplot.opts( color=dim('island').str(), cmap=['red','green','blue'] )

Now, suppose I want to use markers in place of colors for island.

Is there something equivalent to cmap (as in the last line of the script above) for marker?

Scatterplot with colors


Solution

  • You can update the code as below to add markers. I have left the colors as is. If you don't need it, can remove that and just keep the markers alone... You can use markers from here

    scatterplot.opts( color=dim('island').str(), cmap=['red','green','blue'],
                     marker=dim('island').categorize({'Torgersen':'circle', 'Biscoe':'diamond', 'Dream':'dash'}) )
    

    enter image description here