Open 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened 1 year ago
@dklein-pik: Can we maybe find a solution for that? The NAVIGATE template contains a variable named Final Energy|Transportation (w/ bunkers)
, and plotting
d <- "/p/projects/remind/modeltests/remind/output/SSP2-NPi-AMT_2024-06-25_16.01.12/REMIND_generic_SSP2-NPi-AMT.mif" %>%
piamInterfaces::generateIIASASubmission(outputFilename = NULL, mapping = "NAVIGATE", generatePlots = FALSE)
d %>% mip::showAreaAndBarPlots(c("Final Energy|Transportation", "Final Energy|Bunkers"), tot = "Final Energy|Transportation (w/ bunkers)", mainReg= "World", yearsBarPlot = c(2030, 2050))
fails with:
<error/rlang_error>
Error in `.rowNamesDF<-`:
! missing values in 'row.names' are not allowed
---
Backtrace:
▆
1. ├─as_tibble(d) %>% ...
2. ├─mip::showAreaAndBarPlots(...)
3. │ └─... %>% ...
4. └─mip::mipArea(., scales = scales, total = is.null(tot), ylab = lcp)
5. ├─ggplot2::scale_fill_manual(...)
6. │ └─ggplot2:::manual_scale(aesthetics, values, breaks, ..., na.value = na.value)
7. │ └─rlang::is_missing(values)
8. └─mip::plotstyle(levels(x[[dimToStack]]))
9. ├─base::`row.names<-`(`*tmp*`, value = uqEntity)
10. └─base::`row.names<-.data.frame`(`*tmp*`, value = uqEntity)
11. └─base::`.rowNamesDF<-`(x, value = value)
The reason is that mip::plotstyle("Final Energy|Transportation (w/ bunkers)")
returns
Final Energy|Transportation
"#000000"
and the mipArea script is not able to match the color to the variable name.
Removing this line would do it, I guess, but I wonder whether there is a reason for the existence of this line…
Removing this line would do it, I guess, but I wonder whether there is a reason for the existence of this line…
Plotting magpie
objects, which have units in parentheses attached to their variable names.
Removing this line would do it, I guess, but I wonder whether there is a reason for the existence of this line…
Plotting
magpie
objects, which have units in parentheses attached to their variable names.
But most (all?) of the mip functions convert with as.quitte
first, and this code in as.quitte.magpie separates variables and units anyway. I also doubt that it would actually work without that step, given that the code for mipArea
obviously does not work if something that plotstyle guesses to be a unit is still around.
I did not say it is a good reason.
Differentiating entities by unit (
"x (y)"
) inplotstyle()
does not work.@johannah-pik https://github.com/pik-piam/mip/blob/5a7c1cc38cf18b7be7c37860b531d2f379794736/inst/extdata/plotstyle.csv#L631-L636
You might want to replace the parentheses with brackets (
Trucks [<3.5t]
) to get that working.Due to code-quirks, these however work https://github.com/pik-piam/mip/blob/5a7c1cc38cf18b7be7c37860b531d2f379794736/inst/extdata/plotstyle.csv#L661-L665
But maybe you want to be consistent and change it there, too.
@dklein-pik: The origin of these got wiped by the move from svn to git https://github.com/pik-piam/mip/blob/5a7c1cc38cf18b7be7c37860b531d2f379794736/inst/extdata/plotstyle.csv#L331-L336 and Anastasis isn't around anymore https://github.com/pik-piam/mip/blob/5a7c1cc38cf18b7be7c37860b531d2f379794736/inst/extdata/plotstyle.csv#L585
but
plotstyle()
seems to be mostly your thing.Should I clean those up in
./inst/extdata/plotstyle.csv
? I'm working on an improvement toplotstyle()
and would prefer not to carry over legacy edge cases, but issue a warning for entities with units instead.