Announcement

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

  • Scale in graph dot

    Dear all,

    I am having problems with the following code:

    Code:
    graph dot (mean) promedio2017 promedio2018 promedio2019, over(entidad) ///
        yla(80 100 120 140) yscale(range(80 145))
    I would like to spread the dots through the interval specified in the yscale option but here is the result, instead:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	94.0 KB
ID:	1541216




    My data is given by

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str28 entidad int(promedio2017 promedio2018 promedio2019)
    "BARRANQUILLA"         97  97  96
    "BOGOTÁ D.C."         98  97  96
    "BUCARAMANGA"         102 102 100
    "CALI"                101 101  99
    "CARTAGENA DE INDIAS"  95  96  94
    "ESPINAL"              92  93  91
    "MANIZALES"            91  94  91
    "MEDELLÍN"           103 103 103
    "NILO"                 84  84  86
    "Nacional"             98  97  96
    "SOLEDAD"              99 100  99
    end
    However, I would like my graph to look at this end like this one:
    Click image for larger version

Name:	ex.PNG
Views:	1
Size:	55.4 KB
ID:	1541217




    Does anyone know, perhaps, a better way to achieve this?

    Kind regards in advance.

  • #2
    You want the -exclude0- option:
    Code:
    graph dot (mean) promedio2017 promedio2018 promedio2019, over(entidad) ///
        yla(80(5)105) exclude0 leg(pos(6) row(1)) dots(msize(*.25))
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	43.9 KB
ID:	1541237

    Comment


    • #3
      Thank you very much. That was exactly what I needed to do.

      A further question would be, how can I change the legends for "2017" "2018" and "2019" instead of "mean2017", "mean2018" and "mean2019".

      Comment


      • #4
        Try something like

        Code:
        graph dot (asis) ... legend(order(1 "2017" 2 "2018" 3 "2019"))
        legend_options is a clickable link in the help for graph dot.

        I would also recommend more use of lower case and sorting on a key variable.

        Comment

        Working...
        X