Announcement

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

  • Inspecting points on plots

    This is a trivial question, but I have not been able to find an answer anywhere (I apologize if this has already been answered elsewhere and I failed to find it):

    Is it possible to extract information about a single data point of interest from a graph? E.g. let's say I see an outlier on a simple twoway scatter; is there an easy way to review the x & y coordinates of that one particular point?
    As many of you probably know, this very straightforward in, say, Matlab (you can just hover your cursor over a point and its coordinate appear)...but I can't seem to be able to do that in Stata.

    Thanks in advance.
    Jakub

  • #2
    Hi Jakub,

    This is not an elegant solution but will work for outlier data points (the labels will be very congested for data where markers are close together). I don't think you can have an interactive plot, as you would like, but others with more knowledge are free to comment.
    Code:
    sysuse auto, clear
    tostring weight length, gen(ww ll)
    gen for_label = ll + "," + ww
    scatter weight length, mlab(for_label)

    Comment


    • #3
      Thank you Matt. I have tried adding labels (similar to your suggestion) but with 2500 points, the plot gets very congested. Of course, the workaround for that would be to plot just a narrow region of interest that includes the outlier, thus decreasing the point density (making the labels legible). However, that's not only inelegant, but also relatively labor-intensive when I have to review 100s of graphs.
      I was really just hoping for an interactive plot, where I hover my cursor over the outlier and see what its x and y coordinates are. Would appreciate any insights.

      Comment


      • #4
        Jakub, I whole-heatedly agree with your response, it is a poor-mans solution. Hopefully someone else can provide a better one!

        Comment


        • #5
          You can do it in Excel if you have it. Just paste the data in and insert a scatterplot. Below was created with cursor hovering over the point marked in red. (This doesn't answer your "is there an easy way to do this in Stata" question. Also, it sounds like you may use Matlab as your workaround).
          Click image for larger version

Name:	Statalist - Excel scatterplot with point.png
Views:	1
Size:	8.4 KB
ID:	1471347

          Last edited by David Benson; 20 Nov 2018, 16:16.

          Comment


          • #6
            Thank you David...yes, I have used both Matlab and Excel as workarounds to inspect the outlier points, but this is very painful and not amenable to high throughput. I may just have to do all my current work in Matlab (which I am new to) or Excel (which is very painful) but I was really hoping to use Stata, since that's my software of choice :-).

            Comment


            • #7
              One of the following may help:

              https://github.com/bsouthga/stataHC

              https://ideas.repec.org/p/boc/usug14/04.html

              https://econpapers.repec.org/paper/bocscon16/16.htm

              Comment

              Working...
              X