How order the "color legend"
See original GitHub issueHello, is it possible to reorder the legend ? The current order is alphabetic but “values” are numbers, so I want an ascending order. In the dataframe, the column “values” have to be strings to use the color parameter, I can’t use integers.
The code :
ggplot(data=df) + aes(x='algo', y='hv', color='values')
The figure :
Thank you
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to change the order of the color legend?
Have you tried changing the order of your original dimension ? (e.g. V-Colour) r/click it and select Default Properties > Sort then select...
Read more >How to Change GGPlot Legend Order: The Best Reference
Changing the order of legend labels can be achieved by reordering the factor levels of the Species variable mapped to the color aesthetic....
Read more >Seaborn Boxplot Legend colors mismatched after setting ...
This fixed the order issue. I did a quick search after that because my bars were not aligned with the xtick labels. I...
Read more >10.3 Changing the Order of Items in a Legend
You want to change the order of the items in a legend. ... which maps the factor levels to colors that are equally...
Read more >How to Change Order of Items in Matplotlib Legend - Statology
The first item in the legend should be the label that was originally in index position 1 of the old legend (“Assists”); The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is ‘exactly’ like factors and levels in R.
You can access the categorical attributes with df.column.cat. See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Categorical.html
You have to turn your data into a pandas.Categorical
Don’t think you need to provide the optional list when dealing with integers.