#!/usr/bin/python3
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import argparse
def plot_csv(
	file_path,
	line_columns,
	grid_column=None,
	line_colors=None, #ex.['red','blue']
	line_styles=None, #ex.['-','--']
	grid_on=True,
	x_label=None,
	y_label=None,
	xticks_rotation=0,
	title="CSV data plot"
	):
	df=pd.read_csv(file_path)
	fig,ax=plt.subplots(figsize=(10,6))
	for i,col in enumerate(line_columns):
		color=line_colors[i] if line_colors else None
		linestyle=line_styles[i] if line_styles else '-'
		ax.plot(df['Time'], df[col], label=col, color=color, linestyle=linestyle)
	if x_label:
		ax.set_xlabel(x_label)
	if y_label:
		ax.set_ylabel(y_label)
	ax.set_title(title)
	ax.legend()
	plt.tight_layout()
	plt.savefig('graph.png',dpi=300,transparent=True)


def main():

	plot_csv(file_path="data.csv",
		line_columns=["Temperature","Humidity","Wetness"],
		grid_column="Time",
		line_colors=["red","blue","orange"],
		line_styles=["-","--","solid"],
		grid_on=True,
		x_label="Time (s)",
		y_label="values",
		xticks_rotation=45,
		title= "Environmental Data")
	'''
	parser=argparse.ArgumentParser(description="Ploter auto")
	parser.add_argument("--file", type=str, required=True, help="data filename")
	parser.add_argument("--lines",nargs="+",required=True, help="columns sep by space")
	args=parser.parse_args()
	plot_csv(
		file_path=args.file,
		line_columns=args.lines
		)
	'''
if __name__=="__main__":
	main()

