Skip to content
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

scatterlines cannot pass a number as one colorant for the whole scatterline #3551

Closed
2 of 3 tasks
zkk960317 opened this issue Jan 14, 2024 · 1 comment · Fixed by #3586 or #3587
Closed
2 of 3 tasks

scatterlines cannot pass a number as one colorant for the whole scatterline #3551

zkk960317 opened this issue Jan 14, 2024 · 1 comment · Fixed by #3586 or #3587
Labels

Comments

@zkk960317
Copy link

  • are you running newest version (version from docs) ?
    CairoMakie v0.11.5
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on?
    AMD R5 2700 + RX 580
using CairoMakie
scatterlines(1:10,1:10,color=5,colormap=:jet,colorrange=(1,5))

The above codes cannot work and print this: ERROR: MethodError: Cannot convert an object of type Float32 to an object of type Union{ColorTypes.RGBA{Float32}, Vector{ColorTypes.RGBA{Float32}}, Vector{Float32}}

However, this works in lines and scatter

lines(1:10,1:10,color=5,colormap=:jet,colorrange=(1,5))
scatter(1:10,1:10,color=5,colormap=:jet,colorrange=(1,5))

A feasible solution is using vector as follows:

scatterlines(1:10,1:10,color=[5 for _ in 1:10], colormap=:jet, colorrange=(1,5))

but the color of scatter is differ from line. I have to set markercolor and markercolormap and markercolorrange, it's very inelegant.

@zkk960317 zkk960317 added the bug label Jan 14, 2024
@zkk960317
Copy link
Author

zkk960317 commented Jan 14, 2024

In addition, the above codes which set one colorant to object from a colormap will results in a legend error.
Then I found another approach:

using Makie.ColorSchemes
mycolor = ColorSchemes.get(colorschemes[:jet], range(0, 1, 5))
scatterlines(1:10,1:10, color=mycolor[5])

Is it the only correct solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant