def drawRadar_pygal(title, case_data, path, showPlot):
    title = title[0:1] + title[-1:0:-1]
    case_data = case_data[0:1] + case_data[-1:0:-1]

    dark_lighten_style = LightenStyle(theme_color, step=5, max_=10)
    dark_lighten_style1 = LightenStyle('#ff0000')
    colorset = ['#cfefdf', '#a7e1c4', '#76d0a3']

    dark_lighten_style.opacity = 0.5
    dark_lighten_style.background = '#ffffff'
    dark_lighten_style.font_family = "DejaVu Sans"
    dark_lighten_style.legend_font_family = "DejaVu Sans"
    dark_lighten_style.major_label_font_family = "DejaVu Sans"
    dark_lighten_style.title_font_family = "DejaVu Sans"
    dark_lighten_style.tooltip_font_family = "DejaVu Sans"
    dark_lighten_style.label_font_family = "DejaVu Sans"
    dark_lighten_style.label_font_size = 40
    dark_lighten_style.major_label_font_size = 40
    dark_lighten_style.legend_font_size = 40
    dark_lighten_style.colors = [colorset[1], theme_color]
    #     dark_lighten_style.foreground = 'rgba(0, 0, 0, .87)'
    #     raise

    radar_chart = pygal.Radar(show_legend=True,
                              width=1600,
                              height=1200,
                              style=dark_lighten_style,
                              margin=25,
                              spacing=20,
                              stroke_style={'width': 5},
                              dots_size=8,
                              show_dots=1,
                              stroke=1)
    # radar_chart.title = 'V8 benchmark results'
    radar_chart.x_labels = title
    if max(case_data) < 1:
        case_data = [c * 100 for c in case_data]
#     radar_chart.add('Chrome1', [{'value':50,'style': 'fill: False; stroke: red; stroke-width: 4;stroke-dasharray: 15, 10, 5, 10, 15'}]*len(case_data))
    radar_chart.add('Standard score', [50] * len(case_data),
                    fill=True,
                    show_dots=0,
                    stroke_style={
                        'width': 2,
                        'dasharray': '3, 6'
                    })

    radar_chart.add('Your score', case_data)
    #     radar_chart._fill('red')
    radar_chart.y_labels = [0, 50, 100]

    #     radar_chart.render_to_file('plot/Radar_pygal.svg',fill = True)
    radar_chart.render_to_png(path + 'Radar_pygal.png', fill=True)
    if showPlot:
        display({'image/svg+xml': radar_chart.render(fill=True)}, raw=True)
def drawPercentile(percentile, x_label, path, showPlot):

    config = Config()
    config.show_legend = False
    # config.range = (0,1)

    dark_lighten_style = LightenStyle('#336676',
                                      base_style=LightColorizedStyle)
    dark_lighten_style.background = '#ffffff'
    dark_lighten_style.opacity = 1
    dark_lighten_style.font_family = "DejaVu Sans"
    dark_lighten_style.legend_font_family = "DejaVu Sans"
    dark_lighten_style.major_label_font_family = "DejaVu Sans"
    dark_lighten_style.title_font_family = "DejaVu Sans"
    dark_lighten_style.tooltip_font_family = "DejaVu Sans"
    dark_lighten_style.label_font_family = "DejaVu Sans"
    dark_lighten_style.label_font_size = 40
    dark_lighten_style.major_label_font_size = 40

    #     print(dark_lighten_style.to_dict())

    bar_chart = pygal.Bar(config,
                          width=1600,
                          height=1000,
                          rounded_bars=6,
                          style=dark_lighten_style,
                          margin=0)

    bar_chart.x_labels = x_label  #['Concentration', 'Stability', 'Focus Continuity'] #map(str, range(2002, 2013))
    bar_chart.y_labels = (0, 0.2, 0.4, 0.6, 0.8, 1)

    # bar_chart.add('Percentile0', rd1.percentile[0])
    # bar_chart.add('Percentile1', rd1.percentile[1])
    # bar_chart.add('Percentile2', rd1.percentile[2])

    bar_chart.add('Percentile', [{
        'value': 1 - percentile[0],
        'color': selectColor(percentile[0])
    }, {
        'value': 1 - percentile[1],
        'color': selectColor(percentile[1])
    }, {
        'value': 1 - percentile[2],
        'color': selectColor(percentile[2])
    }])
    if showPlot:
        display({'image/svg+xml': bar_chart.render()}, raw=True, dpi=200)

    bar_chart.render_to_png(path + 'Percentile.png', fill=True, dpi=200)
Exemple #3
0
# style.tooltip_font_family = 'Helvetica'
# style.legend_font_family = 'Helvetica'
# style.no_data_font_family = 'Helvetica'

style.title_font_size = 18
style.label_font_size = 13
style.major_label_font_size = 10
# style.value_font_size = 8
# style.value_label_font_size = 8
# style.tooltip_font_size = 11
# style.legend_font_size = 10
# style.no_data_font_size = 48

# style.guide_stroke_dasharray = '2, 4'
style.major_guide_stroke_dasharray = '2, 4'
style.opacity = '.6'
style.opacity_hover = '.9'
# style.transition = '150ms'
# style.colors = ('#E853A0', '#E8537A', '#E95355', '#E87653', '#E89B53')
# style.value_colors = ()

# Config info:
# -----------------------------------------------------------------------------

config = pygal.Config()
config.width = 1200
# config.height = 500
# config.spacing = 50
# config.x_title = 'x-axis'
# config.y_title = 'y-axis'
# config.human_readable = True   # for complex or large numbers