Adding chart title with Vincent/Vega

973 views Asked by At

I am trying to create Vega charts in python using Vincent. 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.

Here is example code from the Vincent website:

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.

1

There are 1 answers

0
Richard On

Got same demand then try to find method like 'set_title' in vincent source code... and no result found. But the 'legend' method may be an alternative of title function, like

bar.legend(title='test')