简体   繁体   English

用Vincent / Vega添加图表标题

[英]Adding chart title with Vincent/Vega

I am trying to create Vega charts in python using Vincent. 我正在尝试使用Vincent在python中创建Vega图表。 Is there a way to add a title to the charts? 有没有办法为图表添加标题? For some reason I cannot find any chart examples created with Vincent and/or Vega that have a chart title on top. 出于某种原因,我找不到任何使用Vincent和/或Vega创建的图表示例,这些示例顶部有图表标题。

Here is example code from the Vincent website: 以下是Vincent网站的示例代码:

import vincent
vincent.core.initialize_notebook()

# dicts of iterables
cat_1 = ['y1', 'y2', 'y3', 'y4']
index_1 = range(0, 21, 1)
multi_iter1 = {'index': index_1}
for cat in cat_1:
    multi_iter1[cat] = [random.randint(10, 100) for x in index_1]

bar = vincent.Bar(multi_iter1['y1'])
bar.axis_titles(x='Index', y='Value')
bar.width=700
bar.height=500
bar.display()

I have tried to do things like bar.title="Chart Title" without success. 我试过做bar.title="Chart Title"这样的事情没有成功。

Got same demand then try to find method like 'set_title' in vincent source code... and no result found. 得到相同的需求然后尝试在vincent源代码中找到像'set_title'这样的方法...并且没有找到结果。 But the 'legend' method may be an alternative of title function, like 但是'传奇'方法可能是标题功能的替代方法,比如

bar.legend(title='test')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM