-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
72 lines (66 loc) · 2.38 KB
/
plot.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
import pandas as pd
import matplotlib.pyplot as plt
from pyautogui import prompt, alert, confirm
def plot(df,X,y,x_label,y_label,heading):
print('\n')
print('''Please enter the type of graph you want to show:
1) Plot \t 2) Scatter plot
3) Histogram \t 4) Boxplot
5) Pie chart \t 6) Bar chart
7) Area plot \t 8) Line plot
''')
print("\n")
type_graph = input('Enter the number = ')
if type_graph == '1':
# want to add a marker in your plot?
marker = input('Do you want to add a marker in your plot? (y/n)')
if marker == 'y' or marker == 'Y' or marker == 'yes' or marker == 'Yes':
marker_input = input('Please enter the marker you want to add eg(*,^) = ')
plt.plot(df[X],df[y],marker = marker_input)
else:
plt.plot(df[X],df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '1':
plt.scatter(df[X], df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '2':
plt.scatter(df[X], df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '3':
plt.hist(df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '4':
plt.boxplot(df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '5':
plt.pie(df[y], labels = df[X])
elif type_graph == '6':
# fwhat bar graph horizontally or vertically
print('''Do you want to show bar graph horizontally or vertically?
\t 1) Horizontal
\t 2) Vertical ''')
ask2 = input('Enter the number: ')
if ask2 == '1':
plt.barh(df[X], df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif ask2 == '2':
plt.bar(df[X], df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
elif type_graph == '7':
plt.plot(df[X], df[y])
plt.xlabel(x_label)
plt.ylabel(y_label)
# after seeing the graph close it to continue
save_fig = input('Do you want to save the graph? (y/n) = ')
if save_fig == 'y' or save_fig == 'Y' or save_fig == 'yes' or save_fig == 'Yes':
plt.savefig(input('Please enter the file name eg (abc.png or abc.jpg) = '))
print('Picture saved in the same folder where I am !! ')
print('Here is the graph .....')
plt.show()