Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grouped bar graph with transparent total

    I am looking to recreate a figure of a grouped bar chart with the total for each category "behind" each set of grouped bars. I have tried to offset the bargap for the total bar with little success. Any suggestions would be greatly appreciated.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str19 scenario float(ID small_pond large_pond small_lake medium_lake large_lake very_large_lake reservoir total)
    "Climate Crisis"      1 12913.62 20083.76  6342.67 19888.83 39969.93 49395.42 4219.146 152813
    "Biodiversity Crisis" 2 7038.104 8508.832  3486.62 10127.08 12435.85 9210.044  2029.45  52836
    "Social Benefits"     3 12260.81 12278.93 4138.455 8890.045  10025.8 1413.561 1570.225  50578
    "Precautionary"       4  6586.87 4813.822 2173.462 4494.024 4778.439 1413.561 679.9336  24940
    end

    Code:
    graph hbar small_pond large_pond small_lake medium_lake large_lake very_large_lake reservoir total, over(scenario, sort(ID)) legend(label(1 "Small Pond") label(2 "Large Pond") label(3 "Small Lake") label(4 "Medium Lake") label(5 "Large Lake") label(6 "Very Large Lake") label(7 "Reservoir") pos(6) row(3) col(3)) bar(1, color(2 129 138)) bar(2, color(1 100 80)) bar(3, color(107 174 214)) bar(4, color(66 146 198)) bar(5, color(33 113 181)) bar(6, color(8 69 148)) bar(7, color(166 189 219)) bar(8, bargap(-50)) ytitle("Water type by FPV generation (GWh)")  name(water_Type, replace)

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	65.1 KB
ID:	1746815

  • #2
    You won't be able to do it with graph hbar, but with some work, you can do it with twoway.I am not volunteering.

    Comment

    Working...
    X