Allow Legend Order to be Set by User #284
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 byread_colors
inutils.py
. Even though the colours are later overridden if the user has specified acolors.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 containregion
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:

After this change:
