facebookresearch / hiplot

HiPlot makes understanding high dimensional data easy
https://facebookresearch.github.io/hiplot/
MIT License
2.75k stars 143 forks source link

Colormap: colormap that centered on zero #173

Closed wuzhe1234 closed 3 years ago

wuzhe1234 commented 3 years ago

Is there any way have a centered on zero colormap?

danthe3rd commented 3 years ago

Hi @wuzhe1234

We use the same scale for the colormap as for the data. So should be able to do something like that:

import hiplot as hip

# Create experiment as usual
column = "metric"
maximum_abs = max(abs(dp.values.get(column, 0)) for dp in experiment.datapoints)
experiment.parameters_definition[column] = ValueDef(type=hip.ValueType.NUMERIC).force_range(minimum=maximum_abs, maximum=-maximum_abs)

# Display experiment as usual
wuzhe1234 commented 3 years ago

Hi @wuzhe1234

We use the same scale for the colormap as for the data. So should be able to do something like that:

import hiplot as hip

# Create experiment as usual
column = "metric"
maximum_abs = max(abs(dp.values.get(column, 0)) for dp in experiment.datapoints)
experiment.parameters_definition[column] = ValueDef(type=hip.ValueType.NUMERIC).force_range(minimum=maximum_abs, maximum=-maximum_abs)

# Display experiment as usual

Thank you, problem solved! I use "hip.ValueDef(value_type=hip.ValueType.NUMERIC)" instead of "hip.ValueDef(type=hip.ValueType.NUMERIC)" to make it work.

Best Regards.