python数据科学基础day15-matplotlib

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import datetime
#散点图
height=[161,170,182,175,173,165]
weight=[50,58,89,80,79,68]
plt.scatter(height,weight)
`

```python
#折线图
x=np.linspace(-10,10,100)
y=x**2
plt.plot(x,y)
#直接用Series作图
ts=pd.Series(np.random.randint(0,50,60),index=pd.date_range('2016-04-25 09:30',periods=60,freq='T'))
ts.plot( linestyle='--',color='red',marker='<')
#柱状图
N=5
y=[20,10,30,39,19]
index=np.arange(N)
p1=plt.bar(x=index,height=y)
plt.show()
#直方图
a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]) 
plt.hist(a, bins =  [0,20,40,60,80,100]) 
plt.title("histogram") 
plt.show()

#heatmap
#Generate a random number, you can refer your data values also
data = np.random.rand(4,2)
rows = list('1234') #rows categories
columns = list('MF') #column categories
fig,ax=plt.subplots()
#Advance color controls
ax.pcolor(data,cmap=plt.cm.Reds,edgecolors='k')
ax.set_xticks(np.arange(0,2)+0.5)
ax.set_yticks(np.arange(0,4)+0.5)
# Here we position the tick labels for x and y axis
ax.xaxis.tick_bottom()
ax.yaxis.tick_left()
#Values against each labels
ax.set_xticklabels(columns,minor=False,fontsize=20)
ax.set_yticklabels(rows,minor=False,fontsize=20)
plt.show()

plt.setp(lines)
#查询绘图的属性(颜色,线条等)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值