-
Notifications
You must be signed in to change notification settings - Fork 1
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
plot_emission_intensity
correctly orders scale_colour_r2dii
input
#528
plot_emission_intensity
correctly orders scale_colour_r2dii
input
#528
Conversation
PTAL: We should look into these deprecation warnings, there's something funky going on there, see #530 |
LGTM. Also tested locally and works as expected. As I mentioned in #527 I would like to try to bring back the ordering of the legend (using a different solution that does not impact the order of the data itself). Will you make an issue about it or should I? |
#534 is the issue, feel free to edit it as you see fit :-) |
@jdhoffa one comment on this. I understood the test as an implied order of colours mapped to categories. I.e. "projected" should be "dark_blue". Running this locally does not return projected as dark blue. So just to be sure: does this fix aim to allow mapping the exact pairs of categories to colours outside the function? If so, great. If the idea was to produce the mapping that I would say the test implies, I don't seem to be able to transfer this to the workflow I am using this on. |
Oh man, ok. Let me have a look tomorrow, maybe i messed something up. |
@jacobvjk can you try this data <- filter(sda, sector == "cement", region == "global") %>%
dplyr::mutate(
emission_factor_metric = factor(
.data$emission_factor_metric,
levels = c(
"projected",
"corporate_economy",
"target_demo",
"adjusted_scenario_demo"
)
)
)
input_colour_scale <- c(
"dark_blue",
"green",
"grey",
"ruby_red"
)
p <- plot_emission_intensity(data)
p <- p + scale_colour_r2dii(
colour_labels = input_color_scale,
) |
@jacobvjk has pointed out that, if a user passes a custom colour scaling to
plot_emission_intensity
, along with specific levels ofemission_factor_metric
to which the scaling should be applied, the result doesn't appear with correct colours.This is caused by an internal function,
match_lines_order
that forcibly changes the levels of the dataset to a custom order (which the user of the function can't know arbitrarily). This means that custom scalings are impossible to achieve consistently, as they will always be applied to the factor levels as ordered within the function.This function was introduced to solve (what seems like) a cosmetic problem, and removing it will likely only have the minor consequence of the legend colour orders not being identical the line colour orders, as they appear on the plot (a UI issue, but not a functional one). See discussion in #527
To fix this:
match_lines_order
labels
tocolour_labels
. The original argument clashed with a required argument name to be passed in through...
Closes #527