Getting Started with Python drawing method examples

Source: Internet
Author: User
This example describes the Python drawing method. Share to everyone for your reference. Specific as follows:

#-*-Coding:utf-8-*-import Matplotlib.pyplot as Pltdef main ():  # Color list    colorlist = [' B ', ' G ', ' R ', ' C ', ' m ', ' y ', ' k ' ]  # Common horizontal    threadlist = [1,2,4,8,10]  # Set the horizontal and ordinate names    plt.xlabel (' Threads ')    Plt.ylabel (' Concurrent ')     # graph title    plt.title (' Concurrent test ')     # The list of lines to draw    lines = []    # corresponds to the name of the line    titles = [ ]    # The ordinate of the first line    dataList1 = [2,5,7,15,30]    # draw the first line according to the horizontal axis and ordinate    line1 = Plt.plot (threadlist, DataList1)    # Set Line color width etc    plt.setp (line1, color=colorlist[0], linewidth=2.0)    # line name    titles.append (' Linux ')    lines.append (line1)     # second line    dataList2 = [2,4,6,18,35]    line2 = Plt.plot (threadlist, DataList2)    Plt.setp (line2, color=colorlist[1], linewidth=2.0)    titles.append (' FreeBSD ')    lines.append (line2)    Plt.legend (lines, titles)    plt.savefig ('/home/workspace/test.png ', dpi=120)    #如果是pdf就, Plt.savefig ( '/home/workspace/test.pdf ') if __name__ = = ' __main__ ':  Main ()

Hopefully this article will help you with Python programming.

  • 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.