File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ # Created by: Brian Shortiss
2+ # Created on: 25 March 2020
3+
4+ # Write a program that displays a plot of the functions f(x)=x, g(x)=x2 and h(x)=x3 in the range [0, 4] on the one set of axes.
5+
6+ # Sources:
7+ # https://realpython.com/how-to-use-numpy-arange/
8+ # https://gist.github.com/aunyks/44648b839e7c59b47afecca62c9a88de
9+
10+
11+ import numpy as np
12+ import matplotlib .pyplot as plt
13+
14+ # Create functions
15+ x = np .arange (0 , 4 ) # Start, Stop
16+
17+ f = x
18+ g = x ** 2
19+ h = x ** 3
20+
21+ # Plot functions
22+ plt .plot (f , 'r' )
23+ plt .plot (g , 'b' )
24+ plt .plot (h , 'g' )
25+
26+ # Plot configuration
27+ plt .legend (['f(x)=x' , 'g(x)=x2' , 'h(x)=x3' ], loc = 'upper left' )
28+ plt .grid ()
29+ plt .xlabel ('X Axis' )
30+ plt .ylabel ('Y Axis' )
31+ plt .title ('Function Plot' )
32+ plt .show ()
You can’t perform that action at this time.
0 commit comments