By plotting a treemap, I added a color code (colorway) in order to have all main parents having the same color scheme. I would now recolor only the minor childs, such as
- all starting with 1 having the same color
- all starting with 2 having the same color
- etc.
Any ideas how I could manage this?
fig <- plot_ly(
type = "treemap",
labels = df$label,
parents = df$parent,
values = df$value / 1000,
branchvalues = "total",
texttemplate = "%{label}: %{value:.1f} TWh",
textinfo = "label+value+percent parent+percent"
) %>%
layout(treemapcolorway = c("#FF0000", "#00A79F", "#413D3A", "B51F1F", "#007480", "#CAC7C7"))
"","label","parent","value"
"1","PV","Electricity techs",71831.99712672
"7","Geothermal","Electricity techs",6096.96
"12","DEC HP Elec","HLT techs",96989.0528080645
"13","Efficiency","Infr. techs",87.6
"15","Grid","Infr. techs",87.6
"19","1 DEC HP Elec","Cp DEC HP Elec",7517.69235287671
"23","5 DEC HP Elec","Cp DEC HP Elec",717.919232876712
"24","6 DEC HP Elec","Cp DEC HP Elec",694.760547945206
"25","7 DEC HP Elec","Cp DEC HP Elec",717.919232876712
"26","8 DEC HP Elec","Cp DEC HP Elec",717.919232876712
"27","9 DEC HP Elec","Cp DEC HP Elec",1198.57438294521
"28","10 DEC HP Elec","Cp DEC HP Elec",3795.63912287671
"30","12 DEC HP Elec","Cp DEC HP Elec",8237.42640287671
"68","2 Efficiency","Cp Efficiency",6.72
"69","3 Efficiency","Cp Efficiency",7.44
"70","4 Efficiency","Cp Efficiency",7.2
"71","5 Efficiency","Cp Efficiency",7.44
"72","6 Efficiency","Cp Efficiency",7.2
"78","12 Efficiency","Cp Efficiency",7.44
"79","1 Geothermal","Cp Geothermal",517.824
"82","4 Geothermal","Cp Geothermal",501.12
"83","5 Geothermal","Cp Geothermal",517.824
"84","6 Geothermal","Cp Geothermal",501.12
"85","7 Geothermal","Cp Geothermal",7.44
"97","7 Grid","Cp Grid",7.44
"98","8 Grid","Cp Grid",7.44
"99","9 Grid","Cp Grid",7.2
"100","10 Grid","Cp Grid",7.44
"101","11 Grid","Cp Grid",7.2
"102","12 Grid","Cp Grid",7.44
"211","1 PV","Cp PV",1971.599921136
"212","2 PV","Cp PV",3158.399873664
"216","6 PV","Cp PV",5651.99977392
"217","7 PV","Cp PV",6100.799755968
"235","Electricity techs","",146522.22744672
"236","HHT techs","",35925.672
"237","HLT techs","",140743.512721477
"238","Infr. techs","",31337.36116834
"239","Cp DEC HP Elec","DEC HP Elec",42725.97
"243","Cp Efficiency","Efficiency",87.6
"244","Cp Geothermal","Geothermal",5243.3856
"245","Cp Grid","Grid",87.6
"255","Cp PV","PV",49553.99801784


