-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotting.py
102 lines (67 loc) · 1.48 KB
/
plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 23 14:15:11 2017
@author: Prafull
"""
import pylab as pl
import numpy as np
x=[1,2,3,4,5]
y=[6,7,8,9,10]
pl.plot(x,y, 'y-^')
pl.plot(x,y, 'y-.')
x=np.random.rand(100)
y=np.random.rand(100)
pl.plot(x,y, 'y-^')
pl.plot(x,y)
x=np.random.randn(100)
y=np.random.randn(100)
pl.plot(x,y, 'y-^')
pl.plot(x,y)
pl.scatter(x,y)
pl.plot(x,y, 'y-o')
pl.plot(np.sin(x))
pl.plot(np.cos(x))
x=np.linspace(-np.pi,np.pi,256,endpoint=True)
c,s=np.cos(x),np.sin(x)
pl.plot(x,c)
pl.plot(x,s)
pl.show()
x=np.linspace(1,110,256,endpoint=True)
c,s=np.cos(x),np.sin(x)
pl.plot(x,c)
pl.plot(x,s)
pl.show()
x=np.arange(50)*2*np.pi/50
y=np.sin(x)
pl.plot(y)
pl.bar(x,y,width=x[1]-x[0])
pl.show()
pl.bar(x,y)
import matplotlib.pyplot as plt
import numpy as np
data=np.random.randn(1000)
f,(ax1,ax2)=plt.subplots(1,2,figsize=(6,3))
ax1.hist(data,bins=30,normed=True,color='b')
ax2.hist(data,bins=10, normed=False, color='r',cumulative=True)
x=[1,2,3,2,1]
y=[3,2,1,3,1]
pl.subplot(2,1,1)
pl.plot(x)
pl.subplot(2,1,2)
pl.plot(y)
x=[1,2,3,2,1]
y=[3,2,1,3,1]
pl.subplot(1,2,1)
pl.plot(x)
pl.subplot(1,2,2)
pl.plot(y)
x=np.random.randn(256)
pl.boxplot(x,vert=0)
pl.show()
samp1=np.random.normal(loc=0,scale=3.,size=200)
samp2=np.random.normal(loc=5.,scale=10.,size=500)
samp3=np.random.normal(loc=0.3,scale=1.2,size=100)
f,ax=plt.subplots(1,1,figsize=(5,4))
ax.boxplot((samp1,samp2,samp3))
ax.set_xticklabels(['sample1','sample2','sample3'])