#!/usr/bin/python3
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
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.index, 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('output.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=["-","--","--"],
	grid_on=True,
	x_label="Time (s)",
	y_label="Values",
	xticks_rotation=45,
	title="Environmental Data")
'''
import argparse
parser=argparse.ArgumentParser(description="Ploter auto")
parser.add_argument("--files", type=str, required=True, help="data filename")
parser.add_argument("--lines", nargs="+", required=True, help="colums sep by space")
args=parser.parse_args()
plot_csv(
	file_path=args.file,
	line_columns=args.lines
	)
if __name__=="__main__":
	main()
