Announcement

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

  • lpattern(dash) option in -twoway- does not work.

    Hello all,

    I've run the syntax below to generate a figure where the three lines the right of the red vertical line should be dashed (as specified by -lpattern(dash)- when year>2020). However, they are still appearing as solid lines. It seems I'm overlooking something here, but am clueless what it might be. Would appreciate any insight you could share.

    Code:
    twoway (scatter yesC_group1_score2 year if year>2020, msymbol(t) mcolor(orange_red)) ///
    (scatter yesC_group2_score2 year if year>2020, msymbol(t) mcolor(black)) ///
    (scatter yesC_group3_score2 year if year>2020, msymbol(t) mcolor(green)) ///
    (line noC_group1`_score2 year if year>2020, lcolor(orange_red) lpattern(dash)) ///
    (line noC_group2_score2 year if year>2020, lcolor(black) lpattern(dash)) ///
    (line noC_group3_score2 year if year>2020, lcolor(green) lpattern(dash)) ///
    (line noC_group1_score year if 2016<year<=2020, lcolor(orange_red) lpattern(solid)) ///
    (line noC_group2_score year if 2016<year<=2020, lcolor(black) lpattern(solid)) ///
    (line noC_group3_score year if 2016<year<=2020, lcolor(green) lpattern(solid)), ///
    title("Test ") xtitle(" Year") xline(2020.5, lcolor(red)) graphregion(color(white)) xlabel(2017(1)2023) ysize(2) xsize(2.5) ylabel(305(5)330, gmin gmax angle(0)) ytitle("Score ") legend(cols(2) order(1 4 2 5 3 6 7 8) label (1 "Group1") label (1 "Group1 - condition 1") label (2 "Group2 - condition 1") label (3 "Group3 - condition 1") label (4 "Group1 - condition 0") label (5 "Group2 - condition 0") label (6 "Group3 - condition 0")) leg(off)

    Figure:
    Attached Files
    Last edited by Minh Oh; 17 Apr 2024, 10:31.

  • #2
    Data example?

    Comment


    • #3
      Thank you for the reminder! Here it is:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(makeid year yesC_group1_score2 yesC_group2_score2 yesC_group3_score2 noC_group1_score2 noC_group2_score2 noC_group3_score2 noC_group1_score noC_group2_score noC_group3_score)
       63515 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      205573 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248471 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       10444 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      216453 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248244 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      243393 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      103105 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      120644 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
          80 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       53463 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248406 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      118660 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
        1988 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      242345 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      216478 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       84337 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      223096 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      247839 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248433 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      187466 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      164172 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      157194 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      126754 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
        9588 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       16763 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
        6786 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       46061 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      168022 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      167433 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      117128 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      140457 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      213906 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248499 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      120331 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      205452 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       29014 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248049 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
       72517 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      139316 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
         522 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      242822 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      149209 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      248479 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      165146 2017        .         .        .        .        .         . 324.14035  321.9481 321.7028
      213906 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      181106 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      164172 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      140457 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       67401 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      216424 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       84337 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      139316 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       82297 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
         522 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      243393 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      173061 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       53463 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      248244 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      187466 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      248406 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      126754 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
        9588 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       56525 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      117128 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      167433 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      103105 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      242345 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      127563 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       46061 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      240930 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      232205 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       29014 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       44154 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      110420 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      248049 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      223096 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       72517 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       63515 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      157194 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      165605 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      118660 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      149209 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
          80 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       30013 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
      120331 2018        .         .        .        .        .         .  324.2688 321.32535 320.6857
       53463 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
        4103 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       67401 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      118660 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       55912 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      242345 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      117128 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      126754 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       72517 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       33042 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      136074 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       84337 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
        9588 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      232205 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      181106 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       65673 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      248244 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
          80 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       44154 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      173061 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      244617 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      220313 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      103105 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      139079 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      240930 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       75962 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      149209 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      127914 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
       46061 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      241387 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      110420 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      212919 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
        9732 2019        .         .        .        .        .         .  324.3972  320.7026 319.6687
      209369 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       55912 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       38869 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       67401 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       68547 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      110420 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      216709 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      166431 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      118660 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       79103 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      103105 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       86508 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      113910 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       84337 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
        4103 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       39431 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      109017 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       84051 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      127914 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      240930 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       88551 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      126754 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       43777 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       82006 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      181106 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      242345 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      212919 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       93973 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       82439 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       65673 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      220313 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      219648 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
        9732 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
        9588 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       53485 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       69336 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      173061 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
       72686 2020        .         .        .        .        .         .  324.5257  320.0798 318.6516
      178316 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       52956 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       69336 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       79103 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      173061 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       65673 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      109017 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       67401 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       99442 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      196384 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       43777 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       82006 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       88551 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      127914 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       90171 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      216709 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
        4103 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      212919 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      240930 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      220313 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      113910 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      248656 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       93973 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       38869 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      197471 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       43699 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       39431 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      209369 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      181106 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
        7406 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      219648 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      142996 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
      108977 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       72686 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       55912 2021 314.2938 308.33475   309.18 324.6541 319.4571 317.63455         .         .        .
       65673 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      229021 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      216794 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      218364 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       45978 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      124557 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       53538 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       38869 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       88551 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       72686 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
         207 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       61223 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      227881 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      108977 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      234677 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      193543 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
        7406 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      100301 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      227357 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       52956 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       82006 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      142996 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       67706 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       69336 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      196384 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       82439 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      235330 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      126160 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       82156 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       93973 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      127914 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      197471 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
        4103 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      203834 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      141058 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
       68547 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      113910 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      219648 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      232922 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      228989 2022 313.9674 311.30365 310.3835 324.7825 318.8343  316.6175         .         .        .
      
      end


      I also noticed that there was a random ` in the syntax above, so inserting the corrected syntax:

      Code:
        
       twoway (scatter yesC_group1_score2 year if year>2020, msymbol(t) mcolor(orange_red)) ///
      (scatter yesC_group2_score2 year if year>2020, msymbol(t) mcolor(black)) ///
      (scatter yesC_group3_score2 year if year>2020, msymbol(t) mcolor(green)) ///
      (line noC_group1`_score2 year if year>2020, lcolor(orange_red) lpattern(dash)) ///
      (line noC_group2_score2 year if year>2020, lcolor(black) lpattern(dash)) ///
      (line noC_group3_score2 year if year>2020, lcolor(green) lpattern(dash)) ///
      (line noC_group1_score year if 2016<year<=2020, lcolor(orange_red) lpattern(solid)) ///
      (line noC_group2_score year if 2016<year<=2020, lcolor(black) lpattern(solid)) ///
      (line noC_group3_score year if 2016<year<=2020, lcolor(green) lpattern(solid)), ///
      title("Test ") xtitle(" Year") xline(2020.5, lcolor(red)) graphregion(color(white)) xlabel(2017(1)2023) ysize(2) xsize(2.5) ylabel(305(5)330, gmin gmax angle(0)) ytitle("Score ") legend(cols(2) order(1 4 2 5 3 6 7 8) label (1 "Group1") label (1 "Group1 - condition 1") label (2 "Group2 - condition 1") label (3 "Group3 - condition 1") label (4 "Group1 - condition 0") label (5 "Group2 - condition 0") label (6 "Group3 - condition 0")) leg(off)
      Last edited by Minh Oh; 17 Apr 2024, 14:08.

      Comment


      • #4
        On the fourth line there is a typo (grave accent). Removing this, I get dashed lines.

        Code:
        twoway (scatter yesC_group1_score2 year if year>2020, msymbol(t) mcolor(orange_red)) ///
        (scatter yesC_group2_score2 year if year>2020, msymbol(t) mcolor(black)) ///
        (scatter yesC_group3_score2 year if year>2020, msymbol(t) mcolor(green)) ///
        (line noC_group1_score2 year if year>2020, lcolor(orange_red) lpattern(dash)) ///
        (line noC_group2_score2 year if year>2020, lcolor(black) lpattern(dash)) ///
        (line noC_group3_score2 year if year>2020, lcolor(green) lpattern(dash)) ///
        (line noC_group1_score year if 2016<year<=2020, lcolor(orange_red) lpattern(solid)) ///
        (line noC_group2_score year if 2016<year<=2020, lcolor(black) lpattern(solid)) ///
        (line noC_group3_score year if 2016<year<=2020, lcolor(green) lpattern(solid)), ///
        title("Test ") xtitle(" Year") xline(2020.5, lcolor(red)) graphregion(color(white)) xlabel(2017(1)2023) ysize(2) xsize(2.5) ylabel(305(5)330, gmin gmax angle(0)) ytitle("Score ") legend(cols(2) order(1 4 2 5 3 6 7 8) label (1 "Group1") label (1 "Group1 - condition 1") label (2 "Group2 - condition 1") label (3 "Group3 - condition 1") label (4 "Group1 - condition 0") label (5 "Group2 - condition 0") label (6 "Group3 - condition 0")) leg(off)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	48.6 KB
ID:	1750371

        Comment


        • #5
          Thank you for taking the time to check it for me.

          I caught that issue as well, and ran the following, but I still get solid lines! I did notice that you get a vertical red line that is dashed, while mine is a solid line...

          Code:
          twoway (scatter yesC_group1_score2 year if year>2020, msymbol(t) mcolor(orange_red)) ///
                  (scatter yesC_group2_score2 year if year>2020, msymbol(t) mcolor(black)) ///
                  (scatter yesC_group3_score2 year if year>2020, msymbol(t) mcolor(green)) ///
                  (line noC_group1_score2 year if year>2020, lcolor(orange_red) lpattern(dash)) ///  
                  (line noC_group2_score2 year if year>2020, lcolor(black) lpattern(dash)) ///
                  (line noC_group3_score2 year if year>2020, lcolor(green) lpattern(dash)) ///
                  (line noC_group1_score year if 2016<year<=2020, lcolor(orange_red) lpattern(solid)) ///
                  (line noC_group2_score year if 2016<year<=2020, lcolor(black) lpattern(solid)) ///
                  (line noC_group3_score year if 2016<year<=2020, lcolor(green) lpattern(solid)), ///    
              title("Test ") xtitle(" Year") xline(2020.5, lcolor(red)) graphregion(color(white)) xlabel(2017(1)2023) ysize(2) xsize(2.5) ylabel(305(5)330, gmin gmax angle(0)) ytitle("Score ") legend(cols(2) order(1 4 2 5 3 6 7 8) label (1 "Group1") label (1 "Group1 - condition 1") label (2 "Group2 - condition 1") label (3 "Group3 - condition 1") label (4 "Group1 - condition 0") label (5 "Group2 - condition 0") label (6 "Group3 - condition 0")) leg(off)
          Click image for larger version

Name:	Screenshot 2024-04-17 at 4.41.00 PM.png
Views:	1
Size:	162.9 KB
ID:	1750373

          Comment


          • #6
            What version of Stata are you running and what is the name of your scheme? If you have Stata 18, append to the code:

            Code:
            set scheme stcolor
            With versions < 18

            Code:
            set scheme s1color
            If that does not help, update Stata and try again:

            Code:
            update all
            This problem is specific to you as I was not able to reproduce it.

            Comment


            • #7
              Originally posted by Minh Oh View Post
              I did notice that you get a vertical red line that is dashed, while mine is a solid line...
              Being explicit gives me a solid line:


              Code:
              xline(2020.5, lcolor(red) lp(solid))

              Comment


              • #8
                We've not got as far as commenting on code such as


                Code:
                 
                 if 2016<year<=2020
                That doesn't work as you hope. Stata won't hold its breath until the end of the command. It first evaluates
                Code:
                2016 < year
                and the result will be 1 or 0 depending on whether that is true or false. When Stata brings in the second part of the comparison, the result of
                Code:
                1 <= 2020
                and of

                Code:
                0 <= 2020
                will be 1 either way as both comparisons always yield true.


                The best way to test being in that interval is

                Code:
                if inrange(year, 2017, 2020)
                I didn't follow through with your code to see if that is biting with your data, but the code should be revised any way.

                See also (for example) https://journals.sagepub.com/doi/pdf...6867X231162009

                Comment


                • #9
                  Thank you, Andrew and Nick. I have done the checks Andrew suggested and made the revision Nick recommended. However, even after only keeping the lines asking for dashed lines, the 3 lines are still appearing to be solid. For reference, I have Stata 17, Revision 13 (Feb 2024).

                  *update*
                  I just noticed that when generating the figure, Stata very briefly shows the lines to be dashed, but immediately the dashed lines "transform" into solid lines. I wonder if there is something overriding or covering the dashed lines?

                  Would appreciate any wisdom you could share!

                  Code:
                  twoway  (line noC_group1_score2 year if year>2020, lcolor(orange_red) lpattern(dash)) ///  
                          (line noC_group2_score2 year if year>2020, lcolor(black) lpattern(dash)) ///
                          (line noC_group3_score2 year if year>2020, lcolor(green) lpattern(dash)), ///    
                      title("Test ") xtitle(" Year") xline(2020.5, lcolor(red)) graphregion(color(white)) xlabel(2017(1)2023) ysize(2) xsize(2.5) ylabel(305(5)330, gmin gmax angle(0)) ytitle("Score ") legend(cols(2) order(1 4 2 5 3 6 7 8) label (1 "Group1") label (1 "Group1 - condition 1") label (2 "Group2 - condition 1") label (3 "Group3 - condition 1") label (4 "Group1 - condition 0") label (5 "Group2 - condition 0") label (6 "Group3 - condition 0")) leg(off)
                  Click image for larger version

Name:	Screenshot 2024-04-18 at 10.11.31 AM.png
Views:	1
Size:	140.3 KB
ID:	1750465

                  Last edited by Minh Oh; 18 Apr 2024, 08:32.

                  Comment


                  • #10
                    You can contact Technical Services if you are unable to resolve it (see https://www.stata.com/support/tech-support/contact/). They will need your license information before they can process your query.

                    Comment


                    • #11
                      Got it. Thank you!

                      Comment

                      Working...
                      X