def saveHistogram2D(y0,
                  y1,
                  xlabel="",
                  ylabel="",
                  name="Graphe Sans Titre",
                  filename="untitledPlot"):
    """
    Function that stores locally an 2d histogram in a txt file
    to be drawn later.
    -- IN
    y0 : data to plot on the x-axis in an array (int[])
    y1: data to plot ont the y-axis in an array (int[]) (must be same size as y0)
    xlabel : name of the x-axis (string) default = ""
    ylabel : name of the y-axis (string) default = ""
    name : name of the graph (string) default = "Graphe Sans Titre"
    filename : name of the file where to store the final image of the graph, name whithout the extension (string) default = "untitledPlot"
    -- OUT
    returns nothing
    """
    print filename
    with open(filename+".hist2d", 'w') as openfile:
        openfile.write("name:"+name+"\n")
        openfile.write("xlabel:"+xlabel+"\n")
        openfile.write("ylabel:"+ylabel+"\n")
        Utils.drawArray(openfile, y0, "y0")
        Utils.drawArray(openfile, y1, "y1")
        openfile.write("name:"+name+"\n")
def saveHistogram(x,
                  y1,
                  y2=None,
                  y3=None,
                  color1=Constants.colorBluePlotly,
                  color2=Constants.colorOrangePlotly,
                  color3=Constants.colorGreenPlotly,
                  name1="",
                  name2="",
                  name3="",
                  percent=False,
                  xlabel="",
                  ylabel="",
                  typeyaxis="linear",
                  name="Graphe Sans Titre",
                  filename="untitledPlot"):
    """
    Function that stores locally an histogram in a txt file
    to be drawn later.
    -- IN
    x : x labels in an array (str[] or int[])
    y1 : first data to plot in an array (int[])
    y2 : second data to plot in an array *optionnal (int[]) default = None
    y3 : third data to plot in an array *optionnal (int[]) default = None
    color1 : color to plot the data 1, the format must be 'rgb(%r,%g,%b)' with %r,%g and %b in [0..255] (string) default = 'rgb(28,173,228)'
    color2 : color to plot the data 2, the format must be 'rgb(%r,%g,%b)' with %r,%g and %b in [0..255] (string) default = 'rgb(39,206,213)'
    color3 : color to plot the data 3, the format must be 'rgb(%r,%g,%b)' with %r,%g and %b in [0..255] (string) default = 'rgb(62,136,83)'
    name1 : name of the data 1 (string) default = ""
    name2 : name of the data 2 (string) default = ""
    name3 : name of the data 3 (string) default = ""
    percent : boolean that settles if it is needed to normalize the values (boolean) default = False
    xlabel : name of the x-axis (string) default = ""
    ylabel : name of the y-axis (string) default = ""
    typeyaxis : type of y-axis must be 'linear' or 'log' (string) default = "linear"
    name : name of the graph (string) default = "Graphe Sans Titre"
    filename : name of the file where to store the final image of the graph, name whithout the extension (string) default = "untitledPlot"
    -- OUT
    returns nothing
    """
    if x is None or y1 is None:
        print "error : no data to draw"
        return
    with open(filename+".txt", 'w') as openfile:
        openfile.write("name:"+name+"\n")
        openfile.write("xlabel:"+xlabel+"\n")
        openfile.write("ylabel:"+ylabel+"\n")
        openfile.write("typeyaxis:"+typeyaxis+"\n")
        Utils.drawArray(openfile, x, "x")
        Utils.drawArray(openfile, y1, "y1")
        openfile.write("name1:"+name1+"\n")
        openfile.write("percent:"+str(percent)+"\n")
        if y2 is not None:
            Utils.drawArray(openfile, y2, "y2")
            openfile.write("name2:"+name2+"\n")
        if y3 is not None:
            Utils.drawArray(openfile, y3, "y3")
            openfile.write("name3:"+name3+"\n")