Skip to content
Advertisement

Python Matplotlib -> give each x axis a numeric Label

I want to give each x Point a Label. From 0 to Inf.

The Label should be visible at the point, that is the highest.

Function:

JavaScript

Plot

Advertisement

Answer

Here is a minimal working example of what I think you want to achieve.

JavaScript

It generates the following plot. enter image description here

For testing purposes I create 3 arrays of 10 random numbers each. Afterwards you have to find the maximum for each x-point and attach a text to the point via plt.text(), whereas the coordinates are the x-point and the found maximum. The offsets are used to move the text so it does only minimally interfere with the plotted maximas themselves.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement