Announcement

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

  • Scatter Graph with labels and different colors

    Dear all

    I have a small data-set where I have the data for the per capita GDP and the Human Development Index for the year of 2010. I want to plot a scatter graph and I did it by using the simple command of "scatter HDI GDPpc". However, I would like the graph to have a different color for each country as well as a label to say what country each color represents.
    My data is organized with three columns, one that says the country and the other two with the GDP and HDI values.
    Below is he graph I can plot in Stata. As you can see, all the points that represent each country have the same color, thus it's not possible to know what country each point represents.
    Is it possible to differentiate each country?

    I appreciate all the help in advance.

    Best regards
    Afonso Rodrigues


    Attached Files

  • #2
    A different colour for every country? It's possible in principle, but (a) crowding on the scatter plot will be enormous (b) what's your legend going to look like?

    Comment


    • #3
      Originally posted by Nick Cox View Post
      A different colour for every country? It's possible in principle, but (a) crowding on the scatter plot will be enormous (b) what's your legend going to look like?
      Dear Nick Cox

      Thank you for your reply.
      It turns out that if I write this code in Stata - scatter HDI PIBpc, mlabel(Country) - the graph labels each point with the respective country. However, it does it inside the graph witch makes it very confusing since I have a lot of countries. If I could somehow choose a different color for each country, and then label each color below the graph, it would be easier to "read" the information.
      Below is the graph I have plotted with the new code as well as a graph I was doing in excel. The graph in excel is what i wanted to do in Stata, because in order to do it in excel I have to "build" each country individually witch would take too long since I have many countries.

      Attached Files

      Comment


      • #4
        Your graph in #3 shows all too well the problems I suggested would be inevitable in #2. I really don't understand what doing anything in Excel has to do with this fundamental problem. You'd have the same problem in any software.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          Your graph in #3 shows all too well the problems I suggested would be inevitable in #2. I really don't understand what doing anything in Excel has to do with this fundamental problem. You'd have the same problem in any software.
          The graph I was building in Excel has a different color for each country and then has the labels below the graph. If I have a high number of countries in a graph like the Excel one, the "crowded" problem wouldn't exist because in the graph I would only have the dots, while the name of the countries would be below the graph.

          Comment


          • #6
            It would exist. The Stata graph you showed has hundreds of dots (thus the confusion) while your Excel graph has 3 dots - 3 countries. If you did it in excel, you would end up with a legend for 100+ countries, which would have something like 30 lines. Additionally, matching each color of the legend to the point in the graph would be horrible.

            Comment


            • #7
              Originally posted by Igor Paploski View Post
              It would exist. The Stata graph you showed has hundreds of dots (thus the confusion) while your Excel graph has 3 dots - 3 countries. If you did it in excel, you would end up with a legend for 100+ countries, which would have something like 30 lines. Additionally, matching each color of the legend to the point in the graph would be horrible.
              In this image you can see a graph identical as the one I was building in Excel. As you can see, it's not as confusing as the Stata one, because the labels are all in the bottom of the graph. I can do this in Excel but the only way I know how, would take very long because I need to individually add each country into the graph.
              I have already went throw the "help scatter" function in Stata and I really think it is not possible to do a graph like this in Stata.
              I guess I will need to spend some time doing it in Excel.
              I appreciate all the help tho
              Attached Files

              Comment


              • #8
                Sorry, but I really can't see any point in a graph like that. Who wants even to try to study it? At a minimum it requires error-free discrimination between very slightly different colours.

                Comment


                • #9
                  Originally posted by Afonso Rodrigues View Post

                  In this image you can see a graph identical as the one I was building in Excel. As you can see, it's not as confusing as the Stata one, because the labels are all in the bottom of the graph. I can do this in Excel but the only way I know how, would take very long because I need to individually add each country into the graph.
                  I have already went throw the "help scatter" function in Stata and I really think it is not possible to do a graph like this in Stata.
                  I guess I will need to spend some time doing it in Excel.
                  I appreciate all the help tho
                  Hi Afonso Rodrigues,

                  I find this to be as confusing as the STATA one. Its virtually impossible to differentiate similar colors in the legend, it is a pain to find specific countries in the graph (where is Ethiopia, Brazil, Serbia?). This is what we've been trying to tell you. Allowing your graph representations to be unique when 100+ countries are shown is a pain, either you do it using labels (as you did in STATA), or using colors (as you did using Excel).

                  One possibility is to restrict which countries you show (as done here and here) or to show all dots but only label a few (as done here and here). There's a (good) reason why you don't see graphs with so many labels or with so many different categories.

                  Comment

                  Working...
                  X