【发布时间】:2019-08-14 15:54:20
【问题描述】:
我正在 Pygal 中制作折线图。我想将图表的标题居中,但我不知道该怎么做。
我尝试查看 Pygal 文档,但找不到与标题对齐相关的任何内容。这是我所拥有的:
custom_style = Style(
background = 'transparent',
font_family='Avenir',
colors = ['#14A1FF', '#14FF47'],
opacity = .5)
chart = pygal.Line(
style=custom_style,
print_values=True,
interpolate='hermite',
fill=True, dots_size=4,
show_y_guides=False,
legend_at_bottom=True,
legend_at_bottom_columns=2)
chart.title = "Rubik's Cube Solve Times Recorded Over Five Days"
chart.x_labels = ["1", "2", "3", "4", "5"]
chart.x_title = "Day"
chart.y_title = "Seconds"
chart.add("Average of 100", ao100)
chart.add("Average of 25", ao25)
chart.render_to_file('times.svg')
【问题讨论】:
-
当然,正如您所说,文档中没有任何明显的内容。在我看来,您只能获得默认位置,即中心。看起来 X 和 Y 标题相对于轴居中,但图形标题在整个图形中居中(因此轴 + y 轴标题和刻度标签)。这使它看起来偏离中心。这在他们的示例图中 (pygal.org/en/stable) 的 pygal 主页上更为明显。