facultyai / facultyai/scala-plotly-client

Custom colorscales

Ouverte
#19 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement good first issue
Langage dominant
Scala
Étoiles
41
Forks
9
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Plotly supports sending custom colorscales as well as the predefined ones. It might be nice to try and support that.

For instance, the following request body to the Plotly API seems to do what we expect (`POST https://api.plot.ly/v2/plots` ; you need to set the headers `Plotly-Client-Platform` to something (eg. `scala`), `Content-Type` to `application/json` and use basic auth with your username and password):

``` json
{
"figure":{
"data":[
{
"zsrc":"pbugnion:452:0049bf,2b5279,47daf1,964c04,6841d3,961eab",
"type":"heatmap",
"colorscale":[
[
7,
"rgb(165,0,38)"
],
[
7.1111111111111111,
"rgb(215,48,39)"
],
[
7.2222222222222222,
"rgb(244,109,67)"
],
[
7.3333333333333333,
"rgb(253,174,97)"
],
[
8.4444444444444444,
"rgb(254,224,144)"
],
[
8.5555555555555556,
"rgb(224,243,248)"
],
[
8.6666666666666666,
"rgb(171,217,233)"
],
[
8.7777777777777778,
"rgb(116,173,209)"
],
[
8.8888888888888888,
"rgb(69,117,180)"
],
[
9,
"rgb(49,54,149)"
]
]
}
]},
"world_readable":true
}
```

The `colorscale` field seems to be an array of 2-arrays containing a z-value and a color.

I think the following interface would work:

``` scala
// current interface in, eg. contour plots
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale("Viridis"))

// extensions
val customColorscale = Coloscale.fromIterable(
List(7 -> Color.rgb(255, 0, 0), 7.5 -> Color.rgb(128, 128, 0), 8.0 -> Color.rgb(0, 255, 0))
)
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale(customColorscale))

val customColorscale = Coloscale.fromFunction { z =>
if (z < 10.0) { Color.rgb(255, 0, 0) } else { Color.rgb(0, 255, 0) }
}
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale(customColorscale))
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.