Notas de estudio de Python día 16

Sentencia todos los días: no debemos desperdiciar nuestras vidas y debemos poder decir: "He hecho lo que puedo hacer"

Visualización de datos

# Matplotlib montaje 
de importación matplotlib.pyplot AS PLT 
Squares = [1,4,9,16,25 ] 
plt.plot (cuadrados) 
plt.show () 
# Gráfico del drenaje de la línea simple

# Modificar el texto de la etiqueta y las líneas 
de importación matplotlib.pyplot AS plt 
Squares = [1,4,9,16,25 ] 
plt.plot (cuadrados, como anchura de línea =. 5) # línea de espesor 

# Set el título del gráfico, y la coordenada marcado 
plt .title ( " números cuadrados " , fontSize = 24 ) 
plt.xlabel ( " Valor " , fontSize = 14 ) 
plt.ylabel ( " cuadrado del valor " , fontSize = 14 )
 # establecer el tamaño de las marcas de graduación 
plt.tick_params (eje = ' both ' , labelsize = 14 ) 
plt.show ()

# Patrón Corrección 
de importación matplotlib.pyplot AS PLT 
input_values = [1,2,3,4,5 ] 
Squares = [1,4,9,16,25 ] 
plt.plot (input_values, cuadrados, como anchura de línea = 5.) # Grosor de la línea 

# establecer el título del gráfico, y la coordenada etiquetado 
plt.title ( " números cuadrados " , fontSize = 24 ) 
plt.xlabel ( " Valor " , fontSize = 14 ) 
plt.ylabel ( " cuadrado del valor " , fontSize = 14 )
 # ajustar el tamaño de las marcas de graduación 
plt.tick_params (Eje = ' tanto ' , 14 = labelsize) 
plt.show ()

# Uso Scatter () trazada diagrama de dispersión y el estilo 
de importación matplotlib.pyplot AS PLT 
plt.scatter ( 2,4 ) 
plt.show () 

# Modificar 
plt.scatter (2,4, S = 200 es )
 # Set el título del gráfico y un eje de coordenadas marcado 
plt.title ( " números cuadrados " , fontSize = 24 ) 
plt.xlabel ( " Valor " , fontSize = 14 ) 
plt.ylabel ( " cuadrado del valor " , fontSize = 14 )
 # conjunto marcas de escala El tamaño de 
plt.tick_params (axis = ' both ' , which = ' major ', labelize = 14 ) 
plt.show ()

# 使用scatter()绘制绘制一系列点
import matplotlib.pyplot as plt
x_value=[1,2,3,4,5]
y_value=[1,4,9,16,25]
plt.scatter(x_value,y_value,s=100)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)
plt.show()

 

 

 

# 自动计算数据
import matplotlib.pyplot as plt
x_value=list(range(1,1001))
y_value=[x**2 for x in x_value]
plt.scatter(x_value,y_value,s=10)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)

#设置每个坐标轴的取值范围
plt.axis([0,1100,0,1100000])

plt.show()
print("----------------------------------分割线--------------------------------")
# 删除数据点的轮廓
plt.scatter(x_value,y_value,edgecolor='none',s=10)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)

#设置每个坐标轴的取值范围
plt.axis([0,1100,0,1100000])

plt.show()

 

# 自定义颜色
import matplotlib.pyplot as plt
x_value=list(range(1,1001))
y_value=[x**2 for x in x_value]
# 删除数据点的轮廓
plt.scatter(x_value,y_value,c='skyblue',edgecolor='none',s=10)
# c='x',x可以是颜色单词也可以是元组RGB(a,b,c)
# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)

#设置每个坐标轴的取值范围
plt.axis([0,1100,0,1100000])

plt.show()

# 使用颜色映射
import matplotlib.pyplot as plt
x_value=list(range(1,1001))
y_value=[x**2 for x in x_value]

# 删除数据点的轮廓
plt.scatter(x_value,y_value,c=y_value,cmap=plt.cm.Blues,edgecolor='none',s=30)
# c='x',x可以是颜色单词也可以是元组RGB(a,b,c)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)

#设置每个坐标轴的取值范围
plt.axis([0,1100,0,1100000])

plt.show()
# 了解pyplot中所有的颜色映射,访问http://matplotlib.org/
# 点击Examples,向下滚动到ColorExample,再点击colormaps_reference
print("http://matplotlib.org/")

import matplotlib.pyplot as plt
x_value=list(range(1,1001))
y_value=[x**2 for x in x_value]

# 删除数据点的轮廓
plt.scatter(x_value,y_value,c=y_value,cmap=plt.cm.Blues,edgecolor='none',s=30)
# c='x',x可以是颜色单词也可以是元组RGB(a,b,c)

# 设置图表标题并给坐标轴加上标签
plt.title("Square Numbers",fontsize=24)
plt.xlabel("Value",fontsize=14)
plt.ylabel("Square of Value",fontsize=14)
# 设置刻度标记的大小
plt.tick_params(axis='both',which='major',labelsize=14)

#设置每个坐标轴的取值范围
plt.axis([0,1100,0,1100000])

# 自动保存图表
plt.savefig('squares_plot.png',bbox_inches='tight')

 

 

Supongo que te gusta

Origin www.cnblogs.com/python-study-notebook/p/12748713.html
Recomendado
Clasificación