当前位置: 首页>>代码示例>>Python>>正文


Python Line.render_to_file方法代码示例

本文整理汇总了Python中pygal.Line.render_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python Line.render_to_file方法的具体用法?Python Line.render_to_file怎么用?Python Line.render_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygal.Line的用法示例。


在下文中一共展示了Line.render_to_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_time_chart

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render_to_file [as 别名]
    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
开发者ID:burakkose,项目名称:reporter-daemon,代码行数:34,代码来源:generator.py

示例2: Style

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render_to_file [as 别名]
# -*- 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")
开发者ID:mermoldy,项目名称:namd-tools,代码行数:25,代码来源:namd-plot.py


注:本文中的pygal.Line.render_to_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。