First, Brief introduction matplotlib
1. Matplotlib is a powerful toolkit for Python drawing and data visualization
2. Installation method: Pip Install Matplotlib
3. Citation method: Import Matplotlib.pyplot as Plt
4. Drawing function: Plt.plot ()
5. Display Image: Plt.show ()
--Linetype LineStyle (-,-.,--,.. )
-colour color (b,g,r,y,k,w,...
2, plot function draw multiple curves
3, Pandas package support for plot
Three, matplotlib-image annotation
--Set Image title: Plt.title ()
--Set X axis name: Plt.xlabel ()
--Set Y axis name: Plt.ylabel ()
--Set X axis range: Plt.xlim ()
--Set Y axis range: Plt.ylim ()
--Set X-axis scale: plt.xticks ()
--Set Y-axis scale: plt.yticks ()
--Set diagram example: Plt.legend ()
Four, matplotlib example--Drawing mathematical function image
Use the Matplotlib module to draw mathematical functions in a window y=x, y=x2, y=3x3+5x2+2x+1 images, distinguish them using different color lines, and use the legend to show what functions each line represents.
Five, Matplotlib: Canvas and sub-chart
Canvas: Figure
--fig = Plt.figure ()
Figure: Subplot
--ax1 = Fig.add_subplot (2,2,1)
Adjust Sub-chart spacing:
--subplots_adjust (left, bottom, right, top, wspace, hspace)
Vi. supported diagram types for matplotlib-
Seven, matplotlib--plot candlestick chart
There are many function interfaces for drawing financial related graphs in the Matplotlib.finanace sub-package.
Draw a candlestick chart: Matplotlib.finance.candlestick_ochl function
Viii. Sample Code
First download before use: Pip install Matplotlib
---then introduced: Import Matplotlib.pylot as Plt
---drawing function: Plt.plot ()
---display function: plt.show ()
Use Plt.plot? To view its parameters
We can change the shape of this line by adding parameters.
Data analysis using python: "Matplotlib"