def Save():
        picBase = baseFileNames["PICBASE"]
        picFile = picBase + "_" + datTime + ".png"
        FigureCanvasTkAgg.print_png(canvas, picFile)

        configBase = baseFileNames["CONFIGBASE"]
        outFile = configBase + '_' + datTime + '.py'

        xminStr = '# xmin = {0:8.1f}\n'.format(xmin)
        xmaxStr = '# xmax = {0:8.1f}\n'.format(xmax)
        yminStr = '# ymin = {0:8.1f}\n'.format(ymin)
        ymaxStr = '# ymax = {0:8.1f}'.format(ymax)
        minmaxStr = xminStr + xmaxStr + yminStr + ymaxStr

        with open(outFile, "w") as outfile:
            outfile.write(fullTxt)
            outfile.write(minmaxStr)
            outfile.write("\n")

        # Conditionally save raw x-y data
        flag = saveRaw.get()
        if flag is True:
            rawfileBase = baseFileNames["RAWBASE"]
            rawFile = rawfileBase + '_' + datTime + '.txt'
            np.savetxt(rawFile, np.array([xx, yy]).T, fmt='%+2.12e')
コード例 #2
0
ファイル: plot.py プロジェクト: gpurvis94/plotui
class PlotFrame(SubFrame):
    """
    The visual design for the Plot frame.
    """
    def _create_widgets(self):
        self._canvas = FigureCanvasTkAgg(self._c.get_plot_figure(), self)
        self._plot = self._canvas.get_tk_widget()

    def _position_widgets(self):
        self._plot.grid()

    def redraw_canvas(self):
        self._canvas.draw()

    def export_png(self, file_name):
        self._canvas.print_png(file_name)
コード例 #3
0
ファイル: matplotlibLumi.py プロジェクト: Andrej-CMS/cmssw
def drawHTTPstring(fig):
    canvas=CanvasBackend(fig)    
    cherrypy.response.headers['Content-Type']='image/png'
    buf=StringIO()
    canvas.print_png(buf)
    return buf.getvalue()
コード例 #4
0
def drawHTTPstring(fig):
    canvas = CanvasBackend(fig)
    cherrypy.response.headers['Content-Type'] = 'image/png'
    buf = StringIO()
    canvas.print_png(buf)
    return buf.getvalue()
コード例 #5
0
ファイル: definition.py プロジェクト: ShironoYuta/webapptest4
def OutputMonthlyCost(Algo, Term, AitaiM, AitaiN, Month):
    fig_CostMonthly = plt.figure()
    plt.grid(which='both')
    ax_CostMonthly = fig_CostMonthly.add_subplot(111)
    ax_CostMonthly.clear()
    Input_CostMonthly = int(Month)

    #Mの分データ取得
    FileName_MC_pre = Term + "_" + Algo + "_Tokyo_"
    FileName_MC_M = FileName_MC_pre + str(Input_CostMonthly) + "_" + str(
        AitaiM[Input_CostMonthly - 1]) + "_M" + ".csv"
    FileDir_MC_M = str(Term) + "_" + str(Algo) + "_Tokyo_M/"
    FilePath_soutai_MC_M = 'scenarios/' + FileDir_MC_M + FileName_MC_M
    base = os.path.dirname(os.path.abspath(__file__))
    FilePath_MC_M = os.path.normpath(os.path.join(base, FilePath_soutai_MC_M))

    data1 = pd.read_csv(FilePath_soutai_MC_M,
                        header=None,
                        encoding="shift-jis").values.tolist()

    #Nの分データ
    FileName_MC_N = FileName_MC_pre + str(Input_CostMonthly) + "_" + str(
        AitaiN[Input_CostMonthly - 1]) + "_N" + ".csv"
    FileDir_MC_N = str(Term) + "_" + str(Algo) + "_Tokyo_N/"
    FilePath_soutai_MC_N = 'scenarios/' + FileDir_MC_N + FileName_MC_N
    base = os.path.dirname(os.path.abspath(__file__))
    FilePath_MC_N = os.path.normpath(os.path.join(base, FilePath_soutai_MC_N))

    data2 = pd.read_csv(FilePath_soutai_MC_N,
                        header=None,
                        encoding="shift-jis").values.tolist()

    SceMC = []

    for i in range(4):
        CurrentSceMC = []
        days = int(len(data1[i]) / 25)
        NumDays = [k + 1 for k in range(days)]
        #NumDays = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
        for j in range(days):
            day = []
            StartM = j * 25
            StartN = j * 23
            MC_N1 = data2[i][StartN:(StartN + 15)]
            day.extend(MC_N1)
            MC_M = data1[i][StartM:(StartM + 25)]
            day.extend(MC_M)
            MC_N2 = data2[i][(StartN + 15):(StartN + 23)]
            day.extend(MC_N2)
            CurrentSceMC.append((sum(day) / 48))
        SceMC.append(CurrentSceMC)
    for i in range(4):
        ax_CostMonthly.plot(NumDays, SceMC[i])

    ax_CostMonthly.set_xlabel("Day")
    ax_CostMonthly.set_ylabel("erectricity cost[yen/kwh]")
    ax_CostMonthly.set_ylim(8, 16)
    canvas_CostMonthly = FigureCanvasTkAgg(fig_CostMonthly)
    png_output = BytesIO()
    canvas_CostMonthly.print_png(png_output)
    data = png_output.getvalue()
    # HTML側に渡すレスポンスを生成する
    response = make_response(data)
    response.headers['Content-Type'] = 'image/png'
    response.headers['Content-Length'] = len(data)
    return response