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

distinguishable_colors for ColorAlpha? #250

Closed
tlnagy opened this issue Aug 25, 2016 · 11 comments
Closed

distinguishable_colors for ColorAlpha? #250

tlnagy opened this issue Aug 25, 2016 · 11 comments

Comments

@tlnagy
Copy link
Member

tlnagy commented Aug 25, 2016

I'm trying to fix a bug in Gadfly (GiovineItalia/Gadfly.jl#844) and one of things I'm running into is the lack of a distinguishable_colors for the ColorAlpha type:

ERROR: MethodError: no method matching distinguishable_colors(::Int64, ::Array{ColorTypes.RGBA{Float64},1})
Closest candidates are:
  distinguishable_colors(::Integer; kwargs...) at /Users/tamasnagy/.julia/v0.5/Colors/src/colormaps.jl:86
  distinguishable_colors{T<:ColorTypes.Color{T,N}}(::Integer, ::AbstractArray{T<:ColorTypes.Color,1}; transform, lchoices, cchoices, hchoices) at /Users/tamasnagy/.julia/v0.5/Colors/src/colormaps.jl:39
  distinguishable_colors(::Integer, ::ColorTypes.Color{T,N}; kwargs...) at /Users/tamasnagy/.julia/v0.5/Colors/src/colormaps.jl:85

Would it enough to store the transparency values, run distinguishable_colors and add the transparency values back in?

@timholy
Copy link
Member

timholy commented Aug 25, 2016

I'm not even sure what it would mean to have the alpha channel participate in any notion of distinguishability---if you draw a transparent red on top of itself several times, it becomes more red, and consequently isn't very distinguishable from full red.

So adding the alpha after running the opaque version of the algorithm seems to make sense, and at the moment I can't see any justification for those receiving different alpha values from one another. If they are different, which values do you assign to the newly-generated colorants?

@tlnagy
Copy link
Member Author

tlnagy commented Aug 25, 2016

If they are different, which values do you assign to the newly-generated colorants?

What is they in this context?

I'm starting to doubt that I would need to call distinguishable_colors here. Since this is full manual color mode, it might be better to simply trust the user to use distinguishable colors and not enforce it.

@timholy
Copy link
Member

timholy commented Aug 26, 2016

they = the different alpha values in the seed-vector that you pass into distinguishable_colors.

@tlnagy
Copy link
Member Author

tlnagy commented Aug 26, 2016

Ah, I see what you mean. Assign the alpha values to the new color most resembling the color they belong to in the seed-vector?

@timholy
Copy link
Member

timholy commented Aug 27, 2016

To me, that sounds like behavior that the user won't be able to predict without a careful read of the documentation. On balance I think I prefer the MethodError, as I just don't think it makes much sense to talk about distinguishability in the context of an alpha channel.

Can't you call map(color, seed) from Gadfly and then re-add whatever alpha channel makes you happy?

@tlnagy
Copy link
Member Author

tlnagy commented Aug 27, 2016

The MethodError is unfortunate though. Currently, when trying to use your own set of colors to Scale.color_discrete_manual, distinguishable_colors is always applied to the input. I guess one solution would be to not run the distinguishable_colors function if RGBA values are supplied.

@timholy
Copy link
Member

timholy commented Aug 27, 2016

I'd be fine with an informative error message.

@tlnagy
Copy link
Member Author

tlnagy commented Aug 27, 2016

Is that the best behavior though? You want to use some RGBA values in your plot and Gadfly errors out and tells you that you can't give alpha values? That seems a bit strict.

@tlnagy
Copy link
Member Author

tlnagy commented Aug 27, 2016

Note: I'm changing what I'm saying here from the OP. I don't think we should make any changes to Colors.jl, only that I shouldn't call distinguishable_colors when the user supplies RGBA values to the manual plot coloring function in Gadfly.

@timholy
Copy link
Member

timholy commented Aug 27, 2016

Right, I'm saying handle RGBA from the Gadfly side, since there's no obviously correct behavior in general. It would be fine to define a distinguishable_colors method here that gives an informative error message, though.

@kimikage
Copy link
Collaborator

xref: PR #439

@kimikage kimikage reopened this May 12, 2024
@kimikage kimikage closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants