Announcement

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

  • Graph modification: How to modify a line to a "bracket-line", change text to italic and insert character ?

    Attempting to modify the following graph- 3 questions:

    1) Would like to change some of graph text to italic. i.e "Wildtype" but unable to get the syntax right, I guess it must be something with " it:wildtype"

    2) How to modify the lines to brackets?: I have tried, but failed to produce " brackets" that is a line, with two down-pointing lines at each end of a line ( to indicate duration) . In example, similar to the brackets shown in the right side of Figure 3 in the paper by Benn Jann- "Stata Journal (2015) 15, Number 3, pp. 751–755. A note on adding objects to an existing twoway graph"

    3) Insert a character at a given place in the graph: how to insert a character/symbol for death, such as char(134) dagger †. ( See Stata Journal (2004) 4, Number 1, pp. 95–96.Stata tip 6: Inserting awkward characters in the plot. Nicholas J. Cox)



    * Example generated by -dataex-. To install: ssc install dataex

    ssc install xtmod.ado
    ssc install addplot

    clear
    input float newid int(mean sem)
    1 1000 498
    2 1758 397
    3 1285 285
    4 1460 324
    5 1529 290
    6 1700 176
    7 1811 241
    8 2300 367
    9 2045 355
    10 1285 285
    11 . .
    end
    label values newid newid
    label def newid 11 "DEATH", modify



    set scheme dsmoderation

    serrbar mean sem newid, xtitle(Date) ytitle(Virus copies/ml (+sem), margin(medium)) ylabel(#10, valuelabels labsize(small) angle(45)) ///
    xlabel(#10, valuelabels labsize(small) angle(45)) plotregion(margin(5 11.5)) xscale(extend) xsize(7)

    addplot:scatteri 2300 5 2300 6, recast(line) lwidth(medium) text(2430 5.5 "Chloroquine", size(medsmall))

    addplot:scatteri 2300 1.05 2300 3.1, recast(line) lwidth(medium) text(2430 2.1 "Chloroquine", size(medsmall))

    addplot:scatteri 1700 9.8 1700 10.2, recast(line) lwidth(medium) text(1830 10 "Anti-IL6", size(medsmall))

    addplot:scatteri 3750 0.9 3750 8.0, recast(line) lwidth(medium) text(3900 5 "Fake News Killer Disease", size(medium)) text(3600 5 "Wildtype Virus", size(medsmall))

    addplot:scatteri 3750 8.9 3750 11.1, recast(line) lwidth(medium) text(3900 10 "Sorry, Not Fake", size(medium)) text(3600 10 "Wildtype Virus", size(medsmall))

    addplot:scatteri -100 11 -100 11, ms(smplus) msize(ehuge)


    thanks Jannik



  • #2
    Code:
    addplot:scatteri 2300 5 2300 6, recast(line) lwidth(medium) /// 
        text(2430 5.5 "Chloroquine", size(medsmall))
    addplot:scatteri 2300 5 2200 5, recast(line) lwidth(medium) 
    addplot:scatteri 2300 6 2200 6, recast(line) lwidth(medium) 
    
    addplot:scatteri 2300 1.05 2300 3.1, recast(line) lwidth(medium) /// 
        text(2430 2.1 "Chloroquine", size(medsmall))
    addplot:scatteri 2300 1.05 2200 1.05, recast(line) lwidth(medium) 
    addplot:scatteri 2300 3.1  2200 3.1, recast(line) lwidth(medium) 
    
    addplot:scatteri 1700 9.8 1700 10.2, recast(line) lwidth(medium) /// 
        text(1830 10 "Anti-IL6", size(medsmall))
    addplot:scatteri 1700 9.8 1600 9.8, recast(line) lwidth(medium)
    addplot:scatteri 1700 10.2 1600 10.2, recast(line) lwidth(medium)
    
    addplot:scatteri 3750 0.9 3750 8.0, recast(line) lwidth(medium) /// 
        text(3900 5 "Fake News Killer Disease", size(medium)) ///
        text(3600 5 "{it:Wildtype Virus}", size(medsmall))
    addplot:scatteri 3750 0.9 3650 0.9, recast(line) lwidth(medium) 
    addplot:scatteri 3750 8.0 3650 8.0, recast(line) lwidth(medium) 
    
    addplot:scatteri 3750 8.9 3750 11.1, recast(line) lwidth(medium) /// 
        text(3900 10 "Sorry, Not Fake", size(medium)) /// 
        text(3600 10 "{it:Wildtype Virus}", size(medsmall))
    addplot:scatteri 3750 8.9 3650 8.9, recast(line) lwidth(medium)
    addplot:scatteri 3750 11.1 3650 11.1, recast(line) lwidth(medium)
    
    addplot:scatteri -100 11, symbol(i) text(-50 11 "`= ustrunescape("\u2020")'", size(*1.5))

    Comment


    • #3
      Scott:Impressive, brilliant, thank you so much! Exactly what I wanted.

      Your solutions are extremely useful- here is the graph for others to see.

      Thanks again.

      Click image for larger version

Name:	Graph.png
Views:	1
Size:	75.3 KB
ID:	1566784
      Attached Files

      Comment

      Working...
      X