-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (27 loc) · 1001 Bytes
/
Copy pathmain.py
File metadata and controls
38 lines (27 loc) · 1001 Bytes
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
import matplotlib
matplotlib.use('Qt5Agg') # for interactive backend
import matplotlib.pyplot as plt
def plot(x:list, y:list, x_label:str, y_label:str, title:str):
# Create the plot
plt.plot(x, y, marker='o')
# Set labels and title
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.title(title)
# Display grid
plt.grid(True)
# Save the plot
plt.savefig('./images/plot.png', dpi=300, bbox_inches='tight')
# Try to show (will warn if non-interactive)
plt.show()
print("\nPlot saved as plot.png")
if __name__ == "__main__":
# Data points
print("Please Enter your data points:")
x = list(map(int, (input("x : ")).strip().split(",")))
y = list(map(int, (input("y : ")).strip().split(",")))
# labels & title
x_label = input("Enter label for X axis: ").strip()
y_label = input("Enter label for Y axis: ").strip()
title = input("Enter the Title of the graph: ").strip()
plot(x, y, x_label, y_label, title)