Announcement

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

  • Stata graphics problem

    Observed in Stata/MP 15.0 on a Windows platform. If it has been fixed in 15.1, sorry for the false alert.

    It seems that the presence of an apostrophe in value labels confuses some part of the charting ados in Stata making it incorrectly estimate the width of the string. The following code demonstrates the problem:

    Code:
    version 15.0
    clear all
    input byte(id ind grade)
     1 1 1
     1 2 2
     1 3 1
     2 1 2
     2 2 1
     2 3 3
     3 1 1
     3 2 3
     3 3 1
    end
    
    label values ind ind
    label def ind 1 "Indicator 1", modify
    label def ind 2 "Indicator 2", modify
    label def ind 3 "Indicator 3", modify
    
    label values grade instructor_preparation
    label def instructor_preparation 1 "Excellent", modify
    label def instructor_preparation 2 "Very Good", modify
    label def instructor_preparation 3 "Good", modify
    label def instructor_preparation 4 "Fair", modify
    label def instructor_preparation 5 "Poor", modify
    
    graph hbar , over(grade)  over(ind)  scale(0.5) stack asyvar legend(rows(1)) name(g1)
    label def ind 2 "Indicator's 2", modify
    graph hbar , over(grade)  over(ind)  scale(0.5) stack asyvar legend(rows(1)) name(g2)
    The chart named g1 is having correctly estimated widths of the texts, while g2 is incorrect. The only difference between the two is the line between the graphing commands, which inserts the apostrophe character into the value label.

    Thank you, Sergiy Radyakin

    Click image for larger version

Name:	g1.png
Views:	1
Size:	39.4 KB
ID:	1433248

    Click image for larger version

Name:	g2.png
Views:	1
Size:	36.1 KB
ID:	1433249

  • #2
    I am struggling with this same problem. Any other ideas? I am using Stata/SE 15.1 for Windows (64bit) and I just did an update all, but the problem is still occurring. Here is the code for the first graph, which properly reports the coefficient names in the coefplot. Notice that I color in red the only content that will be changed for the second coefplot.

    Code:
    coefplot (est1, mcolor(black) ciopts(lcolor(black))), ///
    drop(_cons othermedia3 city1 1.v22c_presvote2 2.v22c_presvote2 4.v22c_presvote2 5.v22c_presvote2 16.v22c_presvote2 7.v22c_presvote2) xline(0, lcolor(black)) ///
    coeflabels(disagreementstrong3="Network disagreement{sub:{it:e}}" disagreementstrong2="Network disagreement{sub:{it:c}}" heterogeneitystrong3="Disagreeing alters' diversity{sub:{it:e}}" ///
    heterogeneitystrong2="Disagreeing alters' diversity{sub:{it:c}}" zerodiscstrong3="Singleton{sub:{it:e}}" zerodiscstrong2="Singleton{sub:{it:c}}" disagreementcontact3="Disagreement of party contact{sub:{it:e}}" ///
    zerocontact3="No party contact{sub:{it:e}}" hgpedisagree3ciro="Gomes intentn{sub:{it:c}}×HGPE exposure{sub:{it:e}}" disagreementmedia3="Exposure to disagreeing media{sub:{it:e}}" zeromedia3="Unexposed to media{sub:{it:e}}", labsize(small)) ///
    legend(off) graphregion(color(white)) order() plotregion(lstyle(yxline) lcolor(black)) ///
    msize(small) groups(disagreementstrong3 disagreementstrong2 heterogeneitystrong3 heterogeneitystrong2 zerodiscstrong3 zerodiscstrong2 disagreementcontact3 zerocontact3 hgpedisagree3ciro disagreementmedia3 zeromedia3 ="{bf:Independent Variables (Political Intermediaries)}") ///
    headings(disagreementstrong3 = "{bf:Citizen-to-Citizen}" disagreementcontact3 = "{bf:Party-to-Citizen}" disagreementmedia3 = "{bf:Professional-to-Citizen}") ///
    yline(8.25 13.25, lcolor(gs4)) xscale(range(-3.5 3.5)) xlab(-3 -2 -1 0 1 2 3) ///
    xtitle("{bf:Logit Coefficient}")  ///
    title("{bf:Brazil 2002}", size(medsmall) color(black))

    Click image for larger version

Name:	Bra2002IndyCoefPlot.png
Views:	1
Size:	84.6 KB
ID:	1459416

    Now here is the code for the second coefplot. Notice that the only difference is the introduction of the apostrophe. The really odd thing is that there are apostrophes elsewhere in this suboption that do not seem to produce the same problem.

    Code:
    coefplot (est1, mcolor(black) ciopts(lcolor(black))), ///
    drop(_cons othermedia3 city1 1.v22c_presvote2 2.v22c_presvote2 4.v22c_presvote2 5.v22c_presvote2 16.v22c_presvote2 7.v22c_presvote2) xline(0, lcolor(black)) ///
    coeflabels(disagreementstrong3="Network disagreement{sub:{it:e}}" disagreementstrong2="Network disagreement{sub:{it:c}}" heterogeneitystrong3="Disagreeing alters' diversity{sub:{it:e}}" ///
    heterogeneitystrong2="Disagreeing alters' diversity{sub:{it:c}}" zerodiscstrong3="Singleton{sub:{it:e}}" zerodiscstrong2="Singleton{sub:{it:c}}" disagreementcontact3="Disagreement of party contact{sub:{it:e}}" ///
    zerocontact3="No party contact{sub:{it:e}}" hgpedisagree3ciro="Gomes intent'n{sub:{it:c}}×HGPE exposure{sub:{it:e}}" disagreementmedia3="Exposure to disagreeing media{sub:{it:e}}" zeromedia3="Unexposed to media{sub:{it:e}}", labsize(small)) ///
    legend(off) graphregion(color(white)) order() plotregion(lstyle(yxline) lcolor(black)) ///
    msize(small) groups(disagreementstrong3 disagreementstrong2 heterogeneitystrong3 heterogeneitystrong2 zerodiscstrong3 zerodiscstrong2 disagreementcontact3 zerocontact3 hgpedisagree3ciro disagreementmedia3 zeromedia3 ="{bf:Independent Variables (Political Intermediaries)}") ///
    headings(disagreementstrong3 = "{bf:Citizen-to-Citizen}" disagreementcontact3 = "{bf:Party-to-Citizen}" disagreementmedia3 = "{bf:Professional-to-Citizen}") ///
    yline(8.25 13.25, lcolor(gs4)) xscale(range(-3.5 3.5)) xlab(-3 -2 -1 0 1 2 3) ///
    xtitle("{bf:Logit Coefficient}")  ///
    title("{bf:Brazil 2002}", size(medsmall) color(black))
    Click image for larger version

Name:	Bra2002IndyCoefPlot2.png
Views:	1
Size:	59.0 KB
ID:	1459417

    Comment


    • #3
      Did you try to delimit the strings by using compound double quotes, instead, such as
      Code:
      `"enclos'd in compound double quotes"'
      (see also -help macro-)? It would be interesting to know whether this could solve the problem.
      `
      Last edited by Dirk Enzmann; 23 Aug 2018, 18:23.

      Comment


      • #4
        Dirk,
        Thank you for the idea. Unfortunately, this did not solve the problem.

        Comment


        • #5
          Must be a bug in Stata then.
          I don't see any problems with the syntax.

          If anyone else runs into the same problem, use Unicode character u2032 as a replacement for the apostrophe.
          Here is this character to copy on the next line:

          With this substitution it works fine.

          Best, Sergiy Radyakin

          Comment

          Working...
          X