Announcement

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

  • Stata 18 graph is glitchy compared to Stata 17

    Hi,
    I encountered a weird glitch in Stata today. I was trying to rerun the code for a graph I made a few months ago in Stata 18. The code runs, but the graph looks...weird: Click image for larger version

Name:	Screenshot 2026-05-14 at 12.36.33 PM.png
Views:	4
Size:	221.6 KB
ID:	1786096 .

    By contrast, I can run the code in Stata 17 and it generates the graph as desired: Click image for larger version

Name:	Screenshot 2026-05-14 at 12.38.21 PM.png
Views:	2
Size:	254.1 KB
ID:	1786099

    What is going on here? Any help would be much appreciated!

    I have checked that my Stata 18 is up to date.


    Data and code are provided below:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str26 condition double(meanpr_av_ba_grad_2124_age15 meanpr_av_ba_grad_2124_age9 meanpr_av_hs_grad6_age15 meanpr_av_hs_grad6_age9) float order
    "always on Ind. (gr4) mover"  3  3 53 51 1
    "moved off"                  19  2 83 51 4
    "moved on"                    3 19 52 83 3
    "never on Ind. (gr4) mover"  22 22 86 85 2
    end

    * Set scheme
    set scheme s1mono

    * Prep data for plotting
    rename *, lower
    rename mean mean
    reshape wide mean, i(cond) j(var) string
    drop if cond == "full sample"
    gen order = 1 if cond == "always on Ind. (gr4) mover"
    replace order = 2 if cond == "never on Ind. (gr4) mover"
    replace order = 3 if cond == "moved on"
    replace order = 4 if cond == "moved off"

    * Multiply by 100
    foreach var in meanpr_av_ba_grad_2124_age15 meanpr_av_ba_grad_2124_age9 meanpr_av_hs_grad6_age15 meanpr_av_hs_grad6_age9 {
    replace `var' = `var' * 100
    format `var' %9.0g
    }

    *** Generate bar plots
    * hs_grad6
    graph bar meanpr_av_hs_grad6_age9 meanpr_av_hs_grad6_age15, ///
    over(cond, ///
    relabel(1 "Always-on Ind. mover" 4 "Never-on Ind. mover" 3 "Moved onto res." 2 "Moved off res.") ///
    sort(order) label(labsize(small))) ///
    legend(order(1 "Average age 9 nbhd." 2 "Average age 15 nbhd.")) ///
    title("High school completion rates (%) in origin and destination nbhd. by mover type", size(medsmall)) ///
    blabel(bar) ///
    ylabel(0 "0%" 20 "20%" 40 "40%" 60 "60%" 80 "80%", angle(0)) ///
    plotregion(margin(t=5))






    Attached Files

  • #2
    Resovled the issue!


    Code:
    graph set window fontface "Helvetica"

    Comment


    • #3
      Crossed with above

      I can not reproduce the behavior on my copy of Stata 18. Do the following, go to menu Edit->Preferences->Graph preferences, what is the Font on the dialog? Change the font selection to "Arial" if it is not. Then click "OK" or "Apply", exit Stata 18, relaunch Stata 18, try again to see if the issue is fixed.

      Comment


      • #4
        Hi Hua,
        I don't see how to get from Edit to Preferences...

        Click image for larger version

Name:	Screenshot 2026-05-14 at 1.02.15 PM.png
Views:	1
Size:	946.3 KB
ID:	1786104

        Comment


        • #5
          On Mac, it's on main windows menu, under Stata/MP 18.0->Settings, see attached screen shots:

          Click image for larger version

Name:	mac.png
Views:	1
Size:	1.31 MB
ID:	1786108

          Comment

          Working...
          X