Figuring out the coordinates for text labels etc

A lot in this lesson. Are there any best practices for generating these or is it pure mundane trial and error? Seems exceedingly tedious, albeit with effective results.

1 Like

Hi @burddylan,

Could you please next time share also the corresponding mission screen link, to better understand what your question is about?

Anyway, as far as I understood, here you’re asking about text annotations put on a plot, for example to explain some particular features. The answer is: yes, it’s an exclusively trial and error approach, without any universal practices to follow, and this is exactly the reason why it’s so efficient and always case-specific.

It’s true also in the case when you want to add not one but several text annotations on the same graph. Even if after adding the first one you already have some idea about possible values of coordinates, and even if some of the annotations (or all of them) are supposed to be aligned and, hence, would have one of the coordinates in common, you still have to try several times when adding a next annotation, every time visually estimate a new possition, and only in this way select the best coordinates for each annotation.

Thanks for getting back on this Elena!

Wonder if there’s a codable solution for this… :thinking:

1 Like

Hi @burddylan,

Sorry, only now I noticed your next question.

Well, since adding text annotations to a graph is still a very case-specific task, I’d say the only codable part of the solution is when you want to place one annotation strictly below another (or strictly to the left or right). Then, you can fix the known coordinate and, using the for-loop, regulate the other coordinate for each subsequent text annotation.

In all the other cases, just trial and error approach, no other way.

Hope my answer is still useful :joy:

1 Like

This has been bothering me a lot. So, I looked into it further. Hopefully this will be helpful for future readers.

Essentially, the way coordinates were picked in this exercise require almost pure trial and error. However, there appears to be something called “Transforms” that allow you to change the coordinate system. I’m still scratching the surface of it myself, but it seems that using transforms to change coordinate system can remove at least most of the trial and error from the process. See link below:

https://matplotlib.org/stable/tutorials/advanced/transforms_tutorial.html

I used the ax.get_xticks () and ax.get_yticks() to get array of x and y axis coordinates for placing text using ax.text() . Its lot of trial and error but it gets better as you try it few times. Please let me know if you end up finding any better efficient way to manage placing text.