Announcement

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

  • How do I change the color of all axesses in a two y-axis graph?

    I want to change the color of all the axes to gs15, but the right y-axis color is not changing. Please suggest what I can do.


    Code:
    twoway bar Minor_Hurr_Count year, barwidth(1) fcolor("225 115 102") lc("225 115 102") yaxis(1) ///
    || bar Major_Hurr_Count year, barwidth(1) fcolor("141 14 14") lc("141 14 14") yaxis(1) ///
    || line Hurr_Cost_Billions year, yaxis(2) lcolor("0 87 231") lwidth(0.5) ///
    ytitle("Hurricane Count", axis(1)) ///
    ytitle("Cost in Billions ($)", axis(2)) ///
    xtitle(" ") ///
    graphregion(color(white)) ///
    ylabel(, nogrid) ///
    xscale(lc(gs15)) yscale(lc(gs15)) ///
    plotregion(lstyle(solid) lcolor(gs15)) ///
    plotregion(fcolor(white) lcolor(gs15)) ///
    legend(order(1 "Minor Hurricane" 2 "Major Hurricane" 3 "Estimated Damage") ///
    ring(3) row(1) size(small) nobox region(lstyle(none)))


    Last edited by Anupam Ghosh; 16 Jul 2025, 12:58.

  • #2
    Please give us an example we can run and a graph we can see.

    Comment


    • #3
      You just need to specify the axis() option within yscale().

      Example with made-up data follows:
      Code:
      clear
      input int(year Major_Hurr_Count Minor_Hurr_Count) float Hurr_Cost_Billions
      2015 5 20   50.6
      2016 6 18    75.8
      2017 4 22   22.8
      2018 8 20   80.3
      2019 10 16   133.8
      2020 5  18   68.5
      2021 9  21  99.0
      2022 3  23  25.4
      2023 7  17   82.1
      2024 6  19   87.7
      end
      
      twoway bar Minor_Hurr_Count year, barwidth(1) fcolor("225 115 102") lc("225 115 102") yaxis(1) ///
      || bar Major_Hurr_Count year, barwidth(1) fcolor("141 14 14") lc("141 14 14") yaxis(1) ///
      || line Hurr_Cost_Billions year, yaxis(2) lcolor("0 87 231") lwidth(0.5) ///
      ytitle("Hurricane Count", axis(1)) ///
      ytitle("Cost in Billions ($)", axis(2)) ///
      xtitle(" ") ///
      graphregion(color(white)) ///
      ylabel(, nogrid) ///
      xscale(lc(gs15)) yscale(axis(1) lc(gs15)) yscale(axis(2) lc(gs15)) ///
      plotregion(lstyle(solid) lcolor(gs15)) ///
      plotregion(fcolor(white) lcolor(gs15)) ///
      legend(order(1 "Minor Hurricane" 2 "Major Hurricane" 3 "Estimated Damage") ///
      ring(3) pos(6) row(1) size(small) nobox region(lstyle(none))) scheme(stcolor)
      which produces:
      Click image for larger version

Name:	Screenshot 2025-07-17 at 5.59.27 PM.png
Views:	1
Size:	353.7 KB
ID:	1779937

      Last edited by Hemanshu Kumar; 17 Jul 2025, 06:31.

      Comment

      Working...
      X