Announcement

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

  • Make part of x-axis dashed

    Is it possible to make part of the x-axis dashed, with the rest of the x-axis solid? This could be useful if somebody has a break in the years they are plotting, and they want to alert the reader to this break.

    This is possible to do with a line in a graph (see https://www.statalist.org/forums/for...ts-of-the-line), but is it also possible to do with the x-axis?

    As an example, suppose I make a graph as follows. How can I make the x-axis between 2 and 3 dashed?

    Code:
    sysuse auto2, clear
    scatter trunk headroom

  • #2
    Here's a guess, and I would be happy to learn of a better solution.

    You can make the entire x axis dashed,

    Code:
    xsc(lp(dash))

    but making part dashed seems harder. I think you would need to suppress the axis and then draw solid and dashed lines to taste in the same place.

    Comment


    • #3
      Here is an implementation of Nick's solution:

      Code:
      sysuse auto, clear
      tw (scatter trunk headroom, ysc(noline) xline(1, lp(dash) lstyle(grid) lc(gs8))) ///
      (scatteri 0 1 10 1, recast(line) lc(gs8) lstyle(grid)), leg(off) plotregion(margin(zero))
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.8 KB
ID:	1763577

      Comment


      • #4
        Very helpful - thank you Nick Cox and Andrew Musau!

        Comment

        Working...
        X