Skip to content

Commit 0faf92d

Browse files
committed
some simple plottinh
1 parent a4903ff commit 0faf92d

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed
349 Bytes
Binary file not shown.

plotting/data.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mySamples = []
2+
myLinear = []
3+
myQuadratic = []
4+
myCubic = []
5+
myExponential = []
6+
7+
for i in range(0, 30):
8+
mySamples.append(i)
9+
myLinear.append(i)
10+
myQuadratic.append(i**2)
11+
myCubic.append(i**3)
12+
myExponential.append(1.5**i)

plotting/plot.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from data import *
2+
import pylab as plt
3+
4+
plt.figure('lin')
5+
plt.clf()
6+
plt.xlabel('sample points')
7+
plt.ylabel('linear function')
8+
plt.title('Linear')
9+
plt.plot(mySamples, myLinear)
10+
11+
plt.figure('quad')
12+
plt.clf()
13+
plt.plot(mySamples, myQuadratic)
14+
plt.ylabel('qudratic function')
15+
plt.title('Quadratic')
16+
17+
plt.figure('cube')
18+
plt.clf()
19+
plt.xlabel('sample points')
20+
plt.ylabel('cubic function')
21+
plt.plot(mySamples, myCubic)
22+
plt.title('Cubic')
23+
24+
plt.figure('expo')
25+
plt.clf()
26+
plt.ylabel('exponential function')
27+
plt.plot(mySamples, myExponential)
28+
plt.title('Exponential')
29+
30+
plt.show()
31+

plotting/plot_compare.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pylab as plt
2+
from data import *
3+
4+
plt.figure('lin')
5+
plt.clf()
6+
plt.ylim(0, 1000)
7+
plt.plot(mySamples, myLinear)
8+
plt.title("Linear")
9+
10+
plt.figure('quad')
11+
plt.clf()
12+
plt.ylim(0, 1000)
13+
plt.plot(mySamples, myQuadratic)
14+
plt.title("Quadratic")
15+
16+
plt.figure('lin quad')
17+
plt.clf()
18+
plt.plot(mySamples, myLinear, label = 'linear')
19+
plt.plot(mySamples, myQuadratic, label = 'quadratic')
20+
plt.legend(loc = "upper left")
21+
plt.title('Linear vs. Quadratic')
22+
23+
plt.figure('cube exp')
24+
plt.clf()
25+
plt.plot(mySamples, myCubic, label = 'cubic')
26+
plt.plot(mySamples, myExponential, label = 'exponential')
27+
plt.legend()
28+
plt.title('Cubic vs. Exponential')
29+
30+
plt.show()

plotting/plot_custom.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pylab as plt
2+
from data import *
3+
4+
plt.figure('lin quad')
5+
plt.clf()
6+
plt.subplot(211)
7+
plt.ylim(0, 900)
8+
plt.plot(mySamples, myLinear, 'b-', label = 'linear', linewidth = 2.0)
9+
plt.subplot(212)
10+
plt.ylim(0, 900)
11+
plt.plot(mySamples, myQuadratic, 'ro', label = 'quadratic', linewidth = 3.0)
12+
plt.legend(loc = "upper left")
13+
plt.title('Linear vs. Quadratic')
14+
15+
plt.figure('cube exp')
16+
plt.clf()
17+
plt.subplot(121)
18+
plt.ylim(0, 140000)
19+
plt.plot(mySamples, myCubic, 'g^', label = 'cubic', linewidth = 4.0)
20+
plt.subplot(122)
21+
plt.ylim(0, 140000)
22+
plt.plot(mySamples, myExponential, 'r--', label = 'exponential', linewidth = 4.0)
23+
plt.legend()
24+
plt.title('Cubic vs. Exponential')
25+
26+
plt.figure('cube exp log')
27+
plt.clf()
28+
plt.plot(mySamples, myCubic, 'g^', label = 'cubic', linewidth = 4.0)
29+
plt.plot(mySamples, myExponential, 'r--', label = 'exponential', linewidth = 4.0)
30+
plt.yscale('log')
31+
plt.legend()
32+
plt.title('Cubic vs. Exponential')
33+
34+
plt.show()

0 commit comments

Comments
 (0)