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

Allow Legend Order to be Set by User #284

Merged
merged 2 commits into from
May 22, 2019
Merged

Allow Legend Order to be Set by User #284

merged 2 commits into from
May 22, 2019

Conversation

emmahodcroft
Copy link
Member

Currently, for most traits where a colour is specified in a colors.tsv file during export, the order of the colours/traits in the legend will be the order they are specified in the file. This makes it easy for users to re-order legends.

However, for regions trait this did not work, as there are default region colours in /augur/augur/data/colors.tsv, which are read in by default by read_colors in utils.py. Even though the colours are later overridden if the user has specified a colors.tsv file, the order in which they are added from the default file persists (even though dicts don't have order technically).

It was decided that even if the users specify a colors.tsv, if that doesn't contain region but they have a region colorby, the defaults should be used instead. (And in theory, this could be extended to other things added to the default color file.)

As the default file is read before the user file, I found the easiest way to achieve this is simply to delete a key if it already exists in the dict, and re-add it.

Before this change:
image

After this change:
image

@emmahodcroft emmahodcroft requested a review from trvrb May 9, 2019 16:25
@rneher rneher merged commit e9c0cf7 into master May 22, 2019
@rneher rneher deleted the export_legend branch May 22, 2019 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants