Skip to content

failed to reproduce bubble-scatter-plots example from plotly python #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aammfe opened this issue Aug 12, 2021 · 3 comments · Fixed by #171
Closed

failed to reproduce bubble-scatter-plots example from plotly python #124

aammfe opened this issue Aug 12, 2021 · 3 comments · Fixed by #171
Labels
Area: MissingAbstraction Plotly.js functionality that has to be implemented Type: Bug

Comments

@aammfe
Copy link

aammfe commented Aug 12, 2021

Description

I'm using .Net interactive notebooks(v1.0.2409020) in Visual studio code and trying to reproduce bubble-scatter-plots but colors are not not being applied on bubbles.

This is code

### Repro steps
#r "nuget: Plotly.NET, 2.0.0-preview.6"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.6"
open Plotly.NET

let xs =[1; 2; 3; 4]
let ys =[10;11; 12; 13]

Chart.Scatter(xs, ys, StyleParam.Mode.Markers, Name="Markers")
        |> Chart.withMarker(Marker.init(MultiSizes=[40; 60; 80; 100], Colors = ["#4287f5";"#cb23fa";"#23fabd";"#ff7b00"]))

Expected behavior

This is Example From plotly python here colors are working fine.
image

Actual behavior

But here colors are not working
image

Colors should be apply on each Bubble

@aammfe aammfe closed this as completed Aug 12, 2021
@kMutagene kMutagene reopened this Aug 13, 2021
@kMutagene
Copy link
Collaborator

kMutagene commented Aug 13, 2021

Colors the way plotly.js are using them are quite difficult to handle in F#, as it can be a single color or an array. For now the easiest way to get around this when using color arrays is setting the color property manually on the Marker used in the charts:

#r "nuget: Plotly.NET, 2.0.0-preview.6"
open Plotly.NET

let xs =[1; 2; 3; 4]
let ys =[10;11; 12; 13]

Chart.Scatter(xs, ys, StyleParam.Mode.Markers, Name="Markers")
|> Chart.withMarker(
    let m = Marker.init(MultiSizes=[40; 60; 80; 100])
    m?color <- ["#4287f5";"#cb23fa";"#23fabd";"#ff7b00"]
    m
)
|> Chart.Show

image

(btw, Colors not working is a real bug. the property gets set to colors instead of color)

@kMutagene kMutagene added Area: MissingAbstraction Plotly.js functionality that has to be implemented Type: Bug labels Aug 13, 2021
@aammfe
Copy link
Author

aammfe commented Aug 13, 2021

Colors the way plotly.js are using them are quite difficult to handle in F#, as it can be a single color or an array.

why we don't use Discriminated union ?

type Color = Color string | Color [IConvertable<a>]
I'm sure code is wrong but you got the idea.

@kMutagene
Copy link
Collaborator

Color is so central that we would like it to be easily used from C# as well. But yes, a DU would solve this on the F# side and might be the solution we go for eventually if we do not find something better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: MissingAbstraction Plotly.js functionality that has to be implemented Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants