Acquaintance matplotlib




matplotlib.pyplot AS PLT Import
# pyplot first introduced into the module, and specify an alias PLT, so as not to repeatedly enter pyplot
# pyplot module comprises a number of functions used to generate the graph


'' '
data visualization to explore means is represented by visualizing data, he and data mining is closely related to, and data mining refers to the use code to explore the law and the associated data set
of the most popular tools matplotlib, it is a mathematical graphics library, we will use it to create simple charts, such as line charts and scatter FIG

linux installation matplotlib
Contos: yum the install Python -Y-matplotlib
RedHat: $ the sudo Python-APT-GET insstall matplotlib


use pip mounted matplotlib
pip the install --user matplolib
'' '




# draw simple line graph
# squares = [1,4 , 9,16,25]
# #plot () function is plotted in accordance with these numbers meaningful pattern
# plt.plot (Squares)
# # plt.show () open matplotlib viewer, and display graphics drawn
# plt.show ()


# modify the label text and line thickness
# Squares = [1,10,20,30,40,50]
''
we provide input and output values, it does not need to make assumptions about the way to generate output worth
''

= input_values [1,2,3,4,5]
Squares = [1,4,9,16,25]
# linewidth parameter determines the plot (the thickness of the drawn line)
plt.plot (input_values, Squares, linewidth. 5 = )

# set the chart title, and to coordinate axes labeled
plt.title ( "Number The Square", 24-fontSize =)

plt.xlabel ( "Value", fontSize = 14)
#xlable (), ylable () let you able to each shaft is provided title
plt.ylabel ( "Square of the Value", fontSize = 24)

# set the size of tick marks, axis = "both" affects the x-axis and y-axis scale
plt.tick_params (axis = "both" , labelsize = 14)
plt.show ()


Guess you like

Origin www.cnblogs.com/tangcode/p/12010964.html