- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
Latest commit
92 lines (58 loc) · 1.45 KB
/
Copy pathplot.py
File metadata and controls
92 lines (58 loc) · 1.45 KB
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
87
88
89
90
91
### plotting graph - "f(x) = x(squared)"
### between x = 0 to x = 1.5 (steps of 0.01) use blue line
### plot the minimum of function with red dot
importnumpyasnp
importmath
importmatplotlib.pyplotasplt
list_x= []
list_y= []
list_xmin= []
my=0
mx=0
# Create x and y lists
forxinnp.arange(0, 1.5, 0.01):
list_x.append(x)
y=x**x
list_y.append(y)
# Create min points for x and y by working out min position in list_y
foriinrange(len(list_y)):
iflist_y[i]<list_y[my]:
my=i
ymin=round(list_y [my], 2)
xmin=list_x [my]
print(f"(xmin, ymin) = ({xmin}, {ymin})")
# Now create the graph
plt.plot(list_x, list_y, 'b-')
plt.plot(xmin, ymin, 'ro')
plt.xlabel("x axis")
plt.ylabel("y axis")
plt.text(0.2, 1.6, "(xmin, ymin) = (0.37, 0.69)", color='black', fontsize=15)
plt.show()
# mx=0
# for i in range(len(list_x)):
# if list_x[i]<list_x[mx]:
# mx=i
# print(mx)
# xmin = list_x [mx]
# print(xmin)
# ymin_list = sorted(list_y, key=float)
# ymin = ymin_list[0]
# print(ymin)
# for x in list_y:
# while x <= list_y:
# xmin = x
# print(xmin)
# for min in list_y:
# if min < list_y:
# minimum = number
# print(list_y)
# for y in np.arange(0.6, 2.0, 0.01):
# list_y.append(y)
# if y >=0:
# y_cubed = list_y ** 2
# list_ycubed.append(y_cubed)
# print(list_x)
# print(list_ycubed)
# store the data in lists
# list_x.append(x)
# list_y.append(y)