zakandrewking / escher

Build, share, and embed visualizations of metabolic pathways.
https://escher.github.io
Other
210 stars 78 forks source link

Allowing a self defined color scale #281

Closed Midnighter closed 5 years ago

Midnighter commented 5 years ago

I'd love to be able to pass my own defined color scale into Escher. There are two reasons:

  1. At the moment escher splits a data distribution into desired quantiles (or similar) every time a new distribution is drawn but I'd like to use the same consistent scale across many different data sets.
  2. I would love to have full control over colors being drawn at certain exact values and intervals.
zakandrewking commented 5 years ago

Just to restate the options from our discussion @ COBRA:

a) provide an API so a user can provide a function that will determine the color based on data (probably via d3.scale so it's friendly to a scale bar implementation)

b) after #242, color scales will normalize the data scale across any number of loaded datasets. this might do the trick for simple cases

zakandrewking commented 5 years ago

just following up on this

now our color scales do not require a min and max, so you can fully control them with values. does this get you what you need?

new beta release is available now on NPM and the website

Midnighter commented 5 years ago

Sounds cool, I'll try it out. Is it already documented how to create the new kind of scale? And if I try it in a notebook, does the Python package already use the beta release?

zakandrewking commented 5 years ago

The docs are up-to-date here: https://escher.readthedocs.io/en/latest/javascript_api.html#escher.Builder.options.reaction_scale

But it's the same kind of scale as before. We just removed the requirement that you include a max and min in the scale. That way, you can create a nice, consistent scale that survives changes in data.

The Python package isn't ready. You could try installing it from source, but it will be missing some features.

Midnighter commented 5 years ago

Does your closing this issue mean that it's also accessible via the Python package now?

zakandrewking commented 5 years ago

Yup! pip install -U --pre escher