
https://www.csdojo.io/data 下载数据集

- 最简单的绘图
x = [1,2,3]
y = [1,4,9]
plt.plot(x,y)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

- 画两个纵坐标
x = [1,2,3]
y = [1,4,9]
z = [10,5,0]
plt.plot(x,y)
plt.plot(x,z)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y and z')
plt.show()

- 标志不同数值
x = [1,2,3]
y = [1,4,9]
z = [10,5,0]
plt.plot(x,y)
plt.plot(x,z)
plt.title('test plot')
plt.xlabel('x')
plt.ylabel('y and z')
plt.legend(["this is y","this is z"])
plt.show()

- 引入数据
需要注意必须在同一个文件夹下
sample_data = pd.read_csv("sample_data.csv")

indice :指数 index:索引
type(sample_data)

retrive 取出 underscore 下划线
sample_data.column_c


- 取其中的一个数
sample_data.column_c.iloc[1] #取出来第二个参数


x-axis y-axis x轴与y轴
plt.plot(sample_data.column_a,sample_data.column_b)
plt.show()

- 图表两个图像
plt.plot(sample_data.column_a,sample_data.column_b)
plt.plot(sample_data.column_a,sample_data.column_c)
plt.title('column')
plt.xlabel('a')
plt.ylabel('b and c')
plt.legend(['b','c'])
plt.show()

bunch of 一大堆
data = pd.read_csv('countries.csv')

另外一个表格的对比
- 导入美国人口的数据
us_population = data[data.country=='United States']

- 导入中国人口
ch_population = data[data.country == 'China']

-
返回索引的bool
索引
- 绘制美国人口曲线
plt.plot(us_population.year,us.population.population)
plt.show()

- 绘制中国人口曲线
plt.plot(ch_population.year,ch_population.population)
plt.show()


-
百分比
比例
网友评论