Skip to content

Commit 002ff16

Browse files
authored
Sine cosine plot extension
More elaborate version for displaying the graph.
1 parent 5ec4c8f commit 002ff16

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

senocoseno_plot2.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Plot the sine cosine graph instantiating all settings
2+
# Chart will be saved in png format
3+
4+
import pylab as pl
5+
import numpy as np
6+
7+
# Creates a figure of size 8x6 points, 80 points per inch
8+
pl.figure(figsize=(8, 6), dpi=80)
9+
10+
# Creates a new subplot from a 1x1 grid
11+
pl.subplot(1, 1, 1)
12+
13+
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
14+
C, S = np.cos(X), np.sin(X)
15+
16+
# Plot the cosine with a continuous blue line of thickness 1 (pixels)
17+
pl.plot(X, C, color="blue", linewidth=1.0, linestyle="-")
18+
19+
# Plot the sine with a continuous green line of thickness 1 (pixels)
20+
pl.plot(X, S, color="green", linewidth=1.0, linestyle="-")
21+
22+
# Sets the limits on x
23+
pl.xlim(-4.0, 4.0)
24+
25+
# Sets the x marks
26+
pl.xticks(np.linspace(-4, 4, 9, endpoint=True))
27+
28+
# Defines the limits in y
29+
pl.ylim(-1.0, 1.0)
30+
31+
# Sets the y-marks
32+
pl.yticks(np.linspace(-1, 1, 5, endpoint=True))
33+
34+
# Saves the figure using 72 dots per inch
35+
pl.savefig("sencos.png", dpi=72)
36+
37+
# Shows the result on the screen
38+
#pl.show()

0 commit comments

Comments
 (0)