Skip to content

pointColor and category relations #14

@plankter

Description

@plankter

Could you please clarify how to colorize point according to category? Am i right that category point values are should be indexes to pointColor array of hex RGB values?

I have two scenarios in mind:

  1. There are two clusters of points, with points category values, for instance, 5 and 6. How i should map these categories to ["#b0b5fb", "#fbb0b0"] in colormap?

  2. Category values are continuous float intensity numbers between, let's say, [0, 1]. How can i map these to sequential color map, that is calculated like:

import { scaleSequential, rgb, interpolateRainbow } from "d3";

const categories = [0.9142996651785714, 0.6185661394571521, 0.4210590563322369, 0.37805454905440167, 0.6646064142262713,];
const min = Math.min(...categories);
const max = Math.max(...categories);
const colorScale = scaleSequential(interpolateRainbow).domain([min, max]);
const colors: string[] = [];
for (let i = 0; i < categories.length; i++) {
    colors.push(rgb(colorScale(i)).hex());
}

this.scatterplot.set({
    colorBy: "category",
    pointColor: colors,
});

It would be very useful to provide color values directly in point value array. Something like [x, y, category, value, "#fbb0b0"].

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions