Hello, Kallan brother.
I seem to have seen a similar example in the matplotlib example a few days ago, but that seems to be three-dimensional.
After seeing your question, I went back to find it.
And then I thought, the question is essentially showing the text on the figure. Should be possible with the text method.
Without your data, I can only simulate it.
For example: Display numbers on a curve and adjust different colors based on values
Import NumPy as NP Import = np.linspace (0.0, 5.0, += Np.cos (2 * np.pi *'-og', ms=3 ) plt.show ()
ImportNumPy as NPImportMatplotlib.pyplot as PltX= Np.linspace (0.0, 5.0, 100) Y= Np.cos (2 * np.pi *x) plt.figure () Plt.plot (x, Y,'-og', ms=3)# ============================================================#generates a color based on the value of Y, and can of course generate color based on the z generated by x, ycolors = [] forYinchY:ifY > 0.5: Colors.append ('Red') elifY > 0.0: Colors.append ('Yellow') elifY >-0.5: Colors.append ('Green') Else: Colors.append ('Blue')#Show All numbers forx, Y, CinchZip (X, Y, colors): s='{:. 2f}'. Format (y) plt.text (x-0.1, y-0.01, S, Color=c, fontsize=10)#Plt.text can only display text individually, so use loops. #another: x, Y is shifted a little to the left.# ============================================================plt.show ()
Not necessarily useful, but really hope to help you.
Loop implementation: Plot lattice data on contour lines