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 control of categories at levels - add color controls #16

Open
ericmelse opened this issue Apr 18, 2023 · 2 comments
Open

Color control of categories at levels - add color controls #16

ericmelse opened this issue Apr 18, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ericmelse
Copy link

Dear Asjad,
It is great to be able to use Ben Jann's palettes and colrspace to control colors, but, that implies (on first sight) their general use and much less their specific use for color coding categories on leveld. Myself, I am very 'picky' when it comes to the control of colors and rather want to select them individually for about anything. But, let me first follow your guidelines and run my example using:

use "MBO22Keuzedelen_Start_20230413.dta" , clear
gen c_keuzedl=1
replace c_keuzedl=2 if KEUZEDEELKEUZE==3
replace c_keuzedl=3 if KEUZEDEELKEUZE==2
replace c_keuzedl=4 if KEUZEDEELKEUZE==4
label define lbl_c_keuzedl 1 "Oriënteren" 2 "Samenwerken" 3 "Analyseren'" 4 "Reflecteren" , replace
label values c_keuzedl lbl_c_keuzedl
label var c_roc "College"
label var vrouw "Studenten"
label var c_keuzedl "Keuzedeel"
alluvial c_roc vrouw c_keuzedl , laba(90) labs(*1.4) showtot boxw(*20) shares vals(*1.2) valf(%12.2f) valgap(*5) palette(carto) name(roc, replace)

which results in:
Alluvial_test_2_20230418
Never mind the cluttered labels at the levels and the super small level titels (we deal with that later).

Note that I have used palette(carto) and that by inspection of that palette, using:
Palette_Carto_20230418
I analyse where which palette color was used by alluvial, using:
Alluvial_test_2_20230418_Palette_Chk
My first thought is 'how does this come about'? What logic decides to use which color for the individual categories at each level?
Should your code apply some algorithm to 'cherry pick' colors from the palette, possibly people will appreciate that (no pun intended).
But, I would like to be in control and be able to assign (set) selected colors of such palette to the levels.
I can think of various ways of coding that but forgive me for being ignorant what would be the most concise but flexible way of coding.
For example, could:

palettelevels(# "str")
The allocation of the colors of the palette(name) by their code to the categories of the levels used.
Default is palettelevels(auto) for automatic color allocation.
Note that when not all categories or not each level is allocated individually that then their default selected color applies (which might result in the multiple use of such colors).

work in your module?
Like with my Example:
palette(carto) levelcolors(1 "5 2 7" 2 "3 10 7" 3 "6 9 1 8")

Ideally, I also really would like to be able to control the colors using all Stata's parameters for colors, like:

* Functional only when palette("str") is not used:
levelcolors(1 "gs11 green sanb" 2 ""255 255 130%50" "255 130 255*1.1"" 3 blue%40 blue%60 blue%80 blue*1.2")

Well, I submit to you that I am a 'demanding' person.

Best,
Eric

@asjadnaqvi asjadnaqvi added the enhancement New feature or request label Apr 19, 2023
@asjadnaqvi asjadnaqvi self-assigned this Apr 19, 2023
@asjadnaqvi
Copy link
Owner

This has been requested for several packages esp sankey. A potential solution is to add a colorby(variable) option. This allows users to define their own order, highlight certain regions, and keep full control of the colors.

@asjadnaqvi
Copy link
Owner

asjadnaqvi commented Apr 20, 2023

Also the default color order is alphabetical. A numerical or a level sort has been implented in sankey but has not been ported over to alluvial.

Merge with #12

@asjadnaqvi asjadnaqvi changed the title Color control of categories at levels Color control of categories at levels - add color controls Apr 20, 2023
@asjadnaqvi asjadnaqvi moved this from Low priority to Unassigned in StataViz issue tracker Apr 21, 2023
@asjadnaqvi asjadnaqvi moved this from Unassigned to Medium priority in StataViz issue tracker Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Next update
Development

No branches or pull requests

2 participants