Python Financial Data Visualization (two-column data extraction//painting///dual-axis//dual-Graph//two different graphs)

Source: Internet
Author: User

ImportMatplotlib as MplImportNumPy as NPImportMatplotlib.pyplot as Pltnp.random.seed (2000) y= Np.random.standard_normal ((20,2))#print (y)" " Different summation print (Y.cumsum ()) Print (Y.sum (axis=0)) print (Y.cumsum (axis=0) )" "#DrawingPlt.figure (figsize= (7,4)) Plt.plot (y.cumsum (axis=0), linewidth=2.5) Plt.plot (y.cumsum (axis=0),'Bo') Plt.grid (True) Plt.axis ("Tight") Plt.xlabel ('Index') Plt.ylabel ('Values') Plt.title ('a simple plot')
Plt.show ()

2. The following extracts two sets of data, to draw.

ImportMatplotlib as MplImportNumPy as NPImportMatplotlib.pyplot as Pltnp.random.seed (2000) Date= Np.random.standard_normal ((20,2)) Y= Date.cumsum (axis=0)Print(y)#the difference between the following two casesPrint(Y[1])# data obtained is line 1th [ -0.37003581 1.74900181]Print(y[:,0])# obtained is the 1th column of data [1.73673761-0.37003581 0.21302575 0.35026529 ...#DrawingPlt.plot (y[:,0], lw=2.5,label="1st", color='Blue') Plt.plot (y[:, 1], lw=2.5,label="2st", color='Red') Plt.plot (y,'ro')#Add DetailsPlt.title ("A Simple Plot", size=20,color='Red') Plt.xlabel ('Index', size=20) Plt.ylabel ('Values', size=20)#Plt.axis (' tight ')Plt.xlim ( -1,21) Plt.ylim (np.min (y)-1,np.max (y) +1)#Add legendPlt.legend (loc= 0)plt.show ()

3. Double axes.

ImportMatplotlib as MplImportNumPy as NPImportMatplotlib.pyplot as Pltnp.random.seed (2000) Date= Np.random.standard_normal ((20,2)) Y= Date.cumsum (axis=0) y[:,0]=y[:,0]*100fig,ax1 = plt.subplots ()Plt.plot (y[:,0],'b',label= "1st") Plt.plot (y[:,0],'ro') Plt.grid (True) Plt.axis ('Tight') Plt.xlabel ("Index") Plt.ylabel ('Values of 1st') Plt.title ("This is a double axis label")plt.legend (Loc = 0) ax2 = Ax1.twinx ()Plt.plot (y[:,1],'g', label="2st") Plt.plot (y[:,1],'r*') Plt.ylabel ("Values of 2st")plt.legend (Loc = 0)plt.show ()

4. Divided into two graphic paintings.

ImportMatplotlib as MplImportNumPy as NPImportMatplotlib.pyplot as Pltnp.random.seed (2000) Date= Np.random.standard_normal ((20,2)) Y= Date.cumsum (axis=0) y[:,0]=y[:,0]*100plt.figure (figsize= (7,5))      #Determine picture sizePlt.subplot (211)               #determine the position of the first diagram (row, column, number of) two rows, one column, the first figure.Plt.plot (y[:,0],'b', label="1st") Plt.plot (y[:,0],'ro') Plt.grid (True) Plt.axis ('Tight') Plt.xlabel ("Index") Plt.ylabel ('Values of 1st') Plt.title ("This is a double axis label") plt.legend (Loc=0) Plt.subplot ( 212)            #determine the position of the first diagramPlt.plot (y[:,1],'g', label="2st") Plt.plot (y[:,1],'r*') Plt.ylabel ("Values of 2st") plt.legend (Loc=0) plt.show ()

5. Draw two different graphs in two layers (straight-line cubic chart)

ImportMatplotlib as MplImportNumPy as NPImportMatplotlib.pyplot as Pltnp.random.seed (2000) Date= Np.random.standard_normal ((20,2)) Y= Date.cumsum (axis=0) y[:,0]=y[:,0]*100plt.figure (figsize= (7,5))#Determine picture sizePlt.subplot (121)#determine the position of the first diagramPlt.plot (y[:,0],'b', label="1st") Plt.plot (y[:,0],'ro') Plt.grid (True) Plt.axis ('Tight') Plt.xlabel ("Index") Plt.ylabel ('Values', size=20) Plt.title ("1st date Set") plt.legend (Loc=0) Plt.subplot (122)#determine the position of the first diagramPlt.bar (Np.arange (len (y[:,1)), y[:,1],width = 0.5,color='g', label="2nd") # The histogram is descriptive Plt.grid (True) Plt.xlabel ("Index") Plt.title ('2nd date Set') plt.legend (Loc=0) plt.show ()

Python Financial Data Visualization (two-column data extraction//painting///dual-axis//dual-Graph//two different graphs)

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.