Loop implementation: Plot lattice data on contour lines

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.