Good day everyone
I am creating scatter plots in Stata 13 to represent data graphically. I want to add labels to my data points, but since I'm usually working with around 30 data points, there are some labels that overlap in my graph. I know that there are some functions available which I can use to change the angle or alignment of my labels manually, but I want to write some sort of code in my do-file so that the overlapped labels change its position automatically.
I did some research and I can't find a code or function that do this automatically, because I need a code that address the following options:
1. Move the labels of two data points with the same coordinates
2. Move the labels of data points with coordinates that are almost the same
3. BUT one must still be able to see which label and data point correlate with each other.
I am struggling to attach my files, so I'll copy them below. I did change labels and values in my data sheet, because I am not allowed to share any real life data.
I hope somebody can help me!
Thanks
Janneke
DataSheet.xlsx:
The do-file:
clear all
*Changing the directory in order to import the correct data sheet
> cd "C:\Users\JannekeS\Desktop\Excel data"
*Importing
> import excel Name Rate Amount using DataSheet.xlsx
*Creating the Scatter and Labels
> scatter Rate Amount, mlabel(Name)
I am creating scatter plots in Stata 13 to represent data graphically. I want to add labels to my data points, but since I'm usually working with around 30 data points, there are some labels that overlap in my graph. I know that there are some functions available which I can use to change the angle or alignment of my labels manually, but I want to write some sort of code in my do-file so that the overlapped labels change its position automatically.
I did some research and I can't find a code or function that do this automatically, because I need a code that address the following options:
1. Move the labels of two data points with the same coordinates
2. Move the labels of data points with coordinates that are almost the same
3. BUT one must still be able to see which label and data point correlate with each other.
I am struggling to attach my files, so I'll copy them below. I did change labels and values in my data sheet, because I am not allowed to share any real life data.
I hope somebody can help me!
Thanks
Janneke
DataSheet.xlsx:
Apple | 131 | 10 |
Pear | 54 | 17 |
Strawberry | 49 | 9 |
Apricot | 138 | 15 |
Peach | 87 | 13 |
Kiwi | 146 | 11 |
Naartjie | 83 | 17 |
Lemon | 122 | 16 |
Granadilla | 84 | 16 |
Mango | -2 | 18 |
Orange | 86 | 6 |
Banana | 41 | 13 |
Papino | 39 | 14 |
Blueberry | 206 | 4 |
Melon | 52 | 14 |
Watermelon | -21 | 13 |
Malberry | 180 | 18 |
Grape | 214 | 17 |
Plum | -30 | 16 |
Grapefruit | 94 | 15 |
Pineapple | -4.4 | 13 |
Fig | 0 | 0 |
Litchi | 0 | 0 |
clear all
*Changing the directory in order to import the correct data sheet
> cd "C:\Users\JannekeS\Desktop\Excel data"
*Importing
> import excel Name Rate Amount using DataSheet.xlsx
*Creating the Scatter and Labels
> scatter Rate Amount, mlabel(Name)
Comment