MECH3410-P1-Graphs/main.py

50 lines
1.6 KiB
Python
Raw Normal View History

2024-08-25 13:20:40 +00:00
# Mech3410-P1-Graphs
# Cal
#
import os, time
import numpy as np
from tqdm import tqdm
from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphing Lib
# Override Sin & Cos to use & return degrees
#def sin(angle): return np.sin(np.deg2rad(angle))
#def cos(angle): return np.cos(np.deg2rad(angle))
# Make sure the relevant folders folder exists
#folders = ["./images", "./tmp", "./data"]
folders = ["./images"]
for folder in folders:
if not os.path.isdir(folder): os.mkdir(folder)
if __name__ == '__main__':
#This is an example of drawing 4 plots by generating them
graphData = {
"figTitle": "Simple Plot",
"figTitleFontSize": 16,
"figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54
"xLabel": "x label",
"yLabel": "y label",
"plotDim": (2,2),
"subPlots":[]
}
#Create 4 identical plots with different names
for i in range(4):
newPlot = {
"title": f"Graph {i+1}",
"plots": [
{"x":[0,1,2,3,4], "y":[0,1,2,3,4], "label":"Linear"},
{"x":[0,1,2,3,4], "y":[5,5,5,5,5]},
{"x":[4,3,2,1,0], "y":[4,3,2,1,0], "label":"Linear2"},
{"x":0, "type":"axvLine", "label":"Red Vertical Line", "color":"red"},
{"y":6, "type":"axhLine", "label":"Dashed Horizontal Line", "args":{"linestyle":"--"}},
{"type":"scatter", "x":4, "y":4, "label":"A Random Point", "colour":"purple", "args":{"zorder":2}}
]
}
graphData["subPlots"].append(newPlot)
makeGraph(graphData, figSavePath="./images/example.png")