Announcement

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

  • Adding arrows in x-axis

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str8 task byte(beg end t) str1 ml
    "a"      3 4 1 "" 
    "b"   1 5 2 "" 
    "c"    2 7 3 "" 
    "d" 0 5 4 "" 
    "e"    . 7 5 "?"
    "f" 0 . 6 "?"
    end
    
    encode task, gen(tsk)
    
    twoway (rbar beg end tsk if t==1, barw(.2) hor) (rbar beg end tsk if t==2, barw(.2) hor) (rbar beg end tsk if t==3, barw(.2) hor lpattern(shortdash)) (rbar beg end tsk if t==4, barw(.2) hor lpattern(shortdash) lcolor(black)), /*
    
    */ ysc(rev noline) ylab(,val angle(0) notick nogrid) ytitle("") /*
    
    */ xti(Moment, size(small)) xscale(titlegap(3)) /*
    
    */ xlabel(0 "a" 1  "b"  2 "c" 3 "d" 4 "e" 5 "f" 6 "g" 7 "h", labsize(vsmall)) /*
    
    */ leg(off)
    Hello all,

    Is there a way to add arrows in the x-line axis in a graph?

    I was able to do this using the graph editor, but I would like to know if there is a coding solution.

    Retriving
    Click image for larger version

Name:	before.jpg
Views:	1
Size:	16.9 KB
ID:	1660721


    Desired
    Click image for larger version

Name:	desired.jpg
Views:	1
Size:	17.0 KB
ID:	1660722



    Thank you in advance!

  • #2
    Code:
    tw sc mpg weight, xsc(r(1800 5200)) text(9.4 5200 "{&gt}", place(e))

    Comment


    • #3
      Originally posted by Øyvind Snilsberg View Post
      Code:
      tw sc mpg weight, xsc(r(1800 5200)) text(9.4 5200 "{&gt}", place(e))
      Thanks, but I was not able to put the text on top of the x-axis line.

      text(0 8 "{&gt}", place(e)) This does not seem to work. BW

      Comment


      • #4
        Thanks for the reproducible example.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str8 task byte(beg end t) str1 ml
        "a"      3 4 1 ""
        "b"   1 5 2 ""
        "c"    2 7 3 ""
        "d" 0 5 4 ""
        "e"    . 7 5 "?"
        "f" 0 . 6 "?"
        end
        
        drop if t>4
        g y1=4.2
        g y2=4.2
        g x1=-0.3
        g x2=7.3
         
        encode task, gen(tsk)
        
        twoway (rbar beg end tsk if t==1, barw(.2) hor) (rbar beg end tsk if t==2, barw(.2) hor) ///
         (rbar beg end tsk if t==3, barw(.2) hor lpattern(shortdash)) ///
         (rbar beg end tsk if t==4, barw(.2) hor lpattern(shortdash) lcolor(black)) ///
         (pcbarrow y1 x1 y2 x2, lc(gs14) mc(black)), plotregion(margin(0)) /*
        
        */ ysc(rev noline r()) ylab(,val angle(0) notick nogrid) ytitle("") /*
        
        */ xti(Moment, size(small)) xscale(titlegap(3)) /*
        
        */ xsc(r(0 7)) xlabel(0 "a" 1  "b"  2 "c" 3 "d" 4 "e" 5 "f" 6 "g" 7 "h", labsize(vsmall)) /*
        
        */ leg(off)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	17.9 KB
ID:	1660751

        Last edited by Andrew Musau; 20 Apr 2022, 15:55.

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Thanks for the reproducible example.
          Thank you very much. This solves the problem perfectly.

          Comment

          Working...
          X