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

Color aesthetic mapping syntax #1430

Open
Mattriks opened this issue Apr 30, 2020 · 4 comments
Open

Color aesthetic mapping syntax #1430

Mattriks opened this issue Apr 30, 2020 · 4 comments

Comments

@Mattriks
Copy link
Member

Mattriks commented Apr 30, 2020

The current syntax that is allowed for color mapping includes:

  • color=[colorant"red"] (works with some, but not all, Geoms)
  • color=["group label"] see example here
  • color="population" or color=:population # refers to a column in a DataFrame
  • color=3 # refers to a column in a DataFrame
  • color=Col.value() or color=Col.index() for wide-format data

So color="red" has multiple possible meanings.
Here and below are options for a new syntax.

Option 1)

  • color=["red"] (also color=[1]) are always group labels, and color="red" is a color or dataframe column
@Mattriks
Copy link
Member Author

Another example to keep in mind is linestyle=[:dash], which could be interpreted as a categorical or functional variable.

@Mattriks Mattriks mentioned this issue Jul 18, 2020
5 tasks
@Mattriks
Copy link
Member Author

Mattriks commented Jul 18, 2020

Option 2 (typed"string" only syntax)

  • color=colorant"red" and linestyle=linestyle"dash".

@knuesel
Copy link

knuesel commented Mar 30, 2021

What about the following?

  • color="red" and color=:red refer to DataFrame columns
  • color=["red"] refers to a group label
  • color=[:red] refers to a predefined color
  • color=RGB(1,0,0) color=[RGB(1,0,0)] can be used to specify an arbitrary color

The first point seems important to me for consistency with other aesthetics and DataFrame indexing.

@knuesel
Copy link

knuesel commented Mar 30, 2021

I think my previous idea is too inconsistent with how aesthetic=[...] generally works (I didn't realize that color=["red"] works like a DataFrame column with automatic cycling).

Much better to keep the current behavior, where color=[...] treats [...] the same as if it was a DataFrame column (if I understand correctly).

I like option 2, maybe with a shorthand const var"@c_str" = var"@colorant_str" so we can write color=c"red".

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

2 participants