Announcement

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

  • Adding text with value from the data into a graph

    Hello everyone, I have a simple question.

    I use the next data

    Code:
    twoway (scatter mean_income_men year) (line mean_income_men year) (scatter mean_income_women year) (line mean_income_women year)
    I also have the variables "number_of_men" and "number_of_women" which are the numbers of men and women I calculated the variables and "mean_income_men" "mean_income_women" from.
    Now what I look for is simply that in the bottom left side of the graph will be the text "Number of Men = " and after it the mean value of the variable "number_of_men" (all the observations in the data have the same value in this variable), and below it the same thing but for the number of women.

    How can I do that? I'll be very glad if someone can show it to me with a simple code.

    Thank you!

    Fitzgerald

  • #2
    Please provide a data example to illustrate your question (FAQ Advice #12). Otherwise we have to work hard to imagine your data (at a minimum) or invent a data example so that any code we think up can be tested before posting.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Please provide a data example to illustrate your question (FAQ Advice #12). Otherwise we have to work hard to imagine your data (at a minimum) or invent a data example so that any code we think up can be tested before posting.
      I'm sorry.

      But I actually don't know how to upload such example dataset. can you explain to me?

      Fitz

      Comment


      • #4
        Originally posted by Nick Cox View Post
        Please provide a data example to illustrate your question (FAQ Advice #12). Otherwise we have to work hard to imagine your data (at a minimum) or invent a data example so that any code we think up can be tested before posting.
        I created this excel file with data like my own,

        I just want that in the bottom left side of the graph will be the text "Number of Men = " and after it the mean value of the variable "number_of_men", and below it the same thing but for the number of women. Notice that it has this variables have the value in all the observations.

        Thank again,

        Fitzgerald.
        Attached Files

        Comment


        • #5
          Dear FitzGerald Blindman see
          Code:
          help dataex
          in Stata
          Best regards,
          Mukesh

          Comment


          • #6
            please read the FAQ which both describes how to upload usable example data and why uploading a binary file (such as a spreadsheet) is a bad idea

            Comment


            • #7
              This text appears whenever you start a new thread. In short, we have explained it to you and explained where else to look.



              Thanks very much for your interest in posting to Statalist, whether this is your first time or you have done it before.

              We have distilled the experience of many years into Advice on Posting, which you should please now read before posting.

              Much of that experience implies that people often do not do that.

              So here is a distillation of the distillation. But if this is not fully clear, do please read the Advice on Posting as requested.

              Including exact Stata code that reproduces a problem is usually a good idea. You should include code within CODE delimiters.

              Giving a data example (using dataex) that allows your problem to be reproduced is a really good idea. Again, use CODE delimiters to do that. It's as simple as this: we cannot see data you don't show -- or that cannot be loaded as one of Stata's own datasets or from a public place.

              Explaining the exact problem is vital, whether it is an error message, something that happened that you didn't want, or something that didn't happen that you did want.

              More plainly put, postings that claim that something "didn't work" (with no real details) or that ask generally what to do in your project will not usually provoke the reply you seek.

              Please do not post images. Please do not post any attachments whatsoever other than .png attachments showing graphs.

              Comment

              Working...
              X