Announcement

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

  • Mlabel command to label datapoints

    Hello
    I am trying to label the datapoints in the graph below. I want to mark the number of machines by year. Eg, For 2017-2018, there were around 8400 subsidised rotavators. I am using mlabel command but to no help. Am I using the wrong command or wrong order ? Please help.

    twoway (line Rotavator Seed_Drill_cum_Zero_Till year), xlabel(, valuelabel, mlabel, sort)


    Thanks
    Smriti


    Click image for larger version

Name:	B_ZTROTA.png
Views:	1
Size:	24.5 KB
ID:	1501861

  • #2
    mlabel() is an option, not a command. If it were a command you wouldn't implement it like that.

    A deeper problem with your syntax is that there are markers to label. Running this code will show some technique (and a horrible graph, but that is not the issue).

    Code:
    webuse grunfeld
    
    line invest year if company == 1 || scatter invest year if company == 1, ms(none) mlabel(invest)

    Comment


    • #3
      Hello Nick
      Thanks for the response. I corrected my mistake and used the following code:
      twoway (line Rotavator Zero_Till year, mlabel( Rotavator Zero_Till )), xlabel(1(1)3, valuelabel)

      However, it shows no labels on the line. The xlabels are for years.

      I don't understand what is wrong with this.

      Smriti
      Last edited by Saini Smriti; 06 Jun 2019, 04:21.

      Comment


      • #4
        Well, I have already explained what's wrong with it. Marker labels go next to markers. You have no markers. Markers are point symbols. See again #2 where the example shows that you can add markers to a line plot by adding a scatter command that suppresses the marker symbol and then adds marker labels.

        Comment

        Working...
        X