免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2568 | 回复: 0
打印 上一主题 下一主题

整理的DEMO一 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-26 10:26 |只看该作者 |倒序浏览
边学习边整理。方便以后的直接使用处理!
示例一
功能描述:绘制直线的方法
import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[1,4,9,16],"ro",color="blue")  表示直接用点来划、颜色为blue
plt.ylabel("some")
plt.show()
示例二
功能:能够在一个图像里面描述两个子图像出来!
import numpy as np
import matplotlib.pyplot as plt
def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure(1)
plt.subplot(211)          子图像
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
示例三、使用文字说明
import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')  //指定了文字位置与文字内容!
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
有一个问题:如何动态调整其显示的位置呢?
示例四、学习legend 的使用!
将每一条线段的颜色表示哪台主机标识出来!我要的效果就是这个了!
String
Number
upper right
1
upper left
2
lower left
3
lower right
4
right
5
center left
6
center right
7
lower center
8
upper center
9
center
10The location of the legend can be specified by the keyword argument
loc, either by string or a integer number.(这个表是loc的参数值!)
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/84280/showart_2104293.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP