I’ve got a scatter plot with a state abbreviation for each text label. The trouble is overlapping text everywhere. So, I hard-coded a dictionary with a text position for all 51 points (I’m including D.C.) that will solve the problem. Example:
position_dict = {
‘DC’:‘top center’,
‘MS’:‘top center’,
‘LA’:‘top center’,
‘GA’:‘middle left’,
…
}
Question: How do write a function that checks the dictionary for each key and returns the value for that key:
Is this even possible? Or do I need to just kludge my way through this by manually sorting the dataframe so that my text position = an np.array of text positions that are ordered in sync with the order of the dataframe?
I realized that there was no way to avoid manually positioning every label based on where each of the dots fell on the scatterplot so I kludged my way through by making sure that the dictionary, position_dict, order matched my dataframe and then did:
This required going through all 50 labels and manually assigning them a position, but it gave a better result than randomly moving through text positions.