def _generate_time_chart(self, datas):
        """
        After generate a time chart,save to file and return the chart path

        Keyword arguments:
        datas -- Dict object of parsed information for a time chart
        """
        if not datas:
            return ""

        line_chart = Line(x_label_rotation=30, sstyle=LightStyle, human_readable=True)

        indices = sorted(datas.keys())
        time_format = self.options["time_format"]
        line_chart.x_labels = map(lambda x: dateutil.parser.parse(x).strftime(time_format), indices)

        chart_data = {}
        for index in indices:
            for data in datas[index]:
                if chart_data.get(data[0]):
                    chart_data.get(data[0]).append(data[1])
                else:
                    chart_data[data[0]] = [data[1]]

        for key in chart_data:
            line_chart.add(key, chart_data[key])

        path = os.path.join(tempfile.gettempdir(), "time{}.svg".format(str(int(time.time()))))
        line_chart.render_to_file(path)
        logging.info("Time chart was created successfully.")

        return path
Exemple #2
0
    def plot_disp(self):

        s1, s2, s3, x = self.badanie.plotdata()

        chart = Line()
        chart.x_title = 'Czas'
        chart.y_title = 'Ugięcie'
        # chart.title = 'Wykres ugięcia gruntu przy badaniu'
        chart.x_labels = map(str, x)
        chart.x_labels_major_count = 20
        chart.show_minor_x_labels = False
        chart.x_label_rotation = 60
        chart.add('Zrzut 1', s1)
        chart.add('Zrzut 2', s2)
        chart.add('Zrzut 3', s3)
        chart.render(is_unicode=True)
        plotpath = 'plots/plot.svg'
        chart.render_to_file(plotpath)
        ploturl = "file:///home/macwojs/PycharmProjects/Terratest/" + plotpath
        self.main_screen.plotview.load(QUrl(ploturl))
Exemple #3
0
    def _generate_time_chart(self, datas):
        """
        After generate a time chart,save to file and return the chart path

        Keyword arguments:
        datas -- Dict object of parsed information for a time chart
        """
        if not datas:
            return ""

        line_chart = Line(x_label_rotation=30,
                          sstyle=LightStyle,
                          human_readable=True)

        indices = sorted(datas.keys())
        time_format = self.options['time_format']
        line_chart.x_labels = map(
            lambda x: dateutil.parser.parse(x).strftime(time_format), indices)

        chart_data = {}
        for index in indices:
            for data in datas[index]:
                if chart_data.get(data[0]):
                    chart_data.get(data[0]).append(data[1])
                else:
                    chart_data[data[0]] = [data[1]]

        for key in chart_data:
            line_chart.add(key, chart_data[key])

        path = os.path.join(tempfile.gettempdir(),
                            "time{}.svg".format(str(int(time.time()))))
        line_chart.render_to_file(path)
        logging.info("Time chart was created successfully.")

        return path
Exemple #4
0
# -*- coding: utf-8 -*-
import os
from pygal.style import Style
from pygal       import Line

X_AXIS = [ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]
Y_AXIS = [ 3.909, 6.833, 9.520, 12.26, 14.89, 17.58, 20.20, 22.81, 25.96, 28.11, 31.20, 33.46, 36.32, 38.54, 41.58, 44.32, 46.80, 49.74, 52.17, 54.85]

LightStyle = Style ( 
   					    background       ='white',
    					plot_background  ='white',
    					foreground       ='black',
    					foreground_light ='black',
    					foreground_dark  ='black',
    					colors           =('#0100FF', '#9f6767')
   					)

plot = Line(style=LightStyle, x_label_rotation=90)
plot.x_labels = map(str, X_AXIS)
plot.add('Wall time, sec', Y_AXIS) 
plot.render_to_file('namd-plot.svg')
os.system("inkscape -z -e namd-plot.png -w 1024 -h 1024 namd-plot.svg")
os.system("rm namd-plot.svg")