import matplotlib.pyplot as plt

def plot2D(dataframes, column_names,rangeargs=None):

#for i in range(rangeargs[0],rangeargs[1],rangeargs[2]):    
    if rangeargs == None:
        
        for i in dataframes:
            df = i
            #df[1]["Energie"] /= 1000000
           
            #for element in [["TKF mitte","P"],["Compressor","DefrostHeater", "CCompFan" ,"CCompEvapSensor", "CCompSensor", "FgCompSensor"]] :
            #    plt.figure()
            #    df[1][element].plot(grid=True)
            #    plt.suptitle(df[0])
            #    plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0., fancybox=True, shadow=True)
            #    plt.show()
            #    plt.tight_layout(rect=[0,0,1,0.95])
        
            try:
                df[1][column_names].plot(grid=True, drawstyle="steps-mid", linewidth=1, title = df[0])
                plt.minorticks_on()
                plt.grid(b=True, which="both")
                plt.grid(which='minor', linewidth='0.5', color='lightgrey')        
                plt.rcParams['figure.figsize'] = (12, 5)
                plt.show()
                plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0., fancybox=True, shadow=True) 
                plt.tight_layout(rect=[0,0,1,0.95])
            except:
                print("for # {} # at least one wrong column declared".format(df[0]))
                pass
        
            # Shrink current axis by 20%
            #ax = plt.subplot(111)
            #box = ax.get_position()
            #ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
            
            
def plot3D():
    pass
    
    
def subplots3D(xCol,yCol,zCol,framelist):
    fig = plt.figure(zCol)
    fig.subtitle = f"{xCol}, {yCol}, {zCol}"
    
    zmin=0.85
    zmax=0.96
    
    axes = [fig.add_subplot(221, projection='3d'),
            fig.add_subplot(222, projection='3d'),
            fig.add_subplot(223, projection='3d'),
            fig.add_subplot(224, projection='3d')]
    
    
    for frame in enumerate(framelist):
        x = frame[1][1][xCol]
        y = frame[1][1][yCol]
        z = frame[1][1][zCol]

        p = axes[frame[0]].scatter(x,y,z,cmap="cool",c=z,vmin=zmin,vmax=zmax)

        axes[frame[0]].set_xlabel(xCol)
        axes[frame[0]].set_ylabel(yCol)
        axes[frame[0]].set_zlabel(zCol)
        axes[frame[0]].set_title(frame[1][0])
        
        axes[frame[0]].set_xlim(1000,5000)
        axes[frame[0]].set_ylim(0,200)
        axes[frame[0]].set_zlim(zmin,zmax)
        
        
    fig.colorbar(p)