pip install --user matplotlib
import matplotlib.pyplot as pyplot
square = [1,4,9,16,25]
pyplot.plot(squares)
pyplot.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
squares = [1,4,9,16,25]
pyplot.plot(squares,linewidth=5)
# 设置图表标题,并给坐标轴加上标签
pyplot.title("Square Numbers",fontsize=24)
pyplot.xlabel("Value",fontsize=14)
pyplot.ylabel("Square of Value",fontsize=14)
#设置刻度标记的大小
pyplot.tick_params(axis="both",labelsize=14)
pyplot.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
input_values = [1,2,3,4,5]
squares = [1,4,9,16,25]
pyplot.plot(input_values,squares,linewidth=5)
pyplot.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
pyplot.scatter(2,4)
pyplot.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
x_values = [1,2,3,4,5]
y_values = [1,4,9,16,25]
pyplot.scatter(x_values,y_values,s=100)
pyplot.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pyplot
x_values = list(range(1,20))
y_values = [x**2 for x in x_values]
pyplot.scatter(x_values,y_values,s=100)
pyplot.show()
pyplot.scatter(x_values,y_values,c='red',s=100)
pyplot.scatter(x_values,y_values,c=y_values,cmap=pyplot.cm.Blues,s=100)
# pyplot.show()
pyplot.savefig('squares_plot.png',bbox_inches='tight')