Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding chart title with Vincent/Vega

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.

like image 434
bobfet1 Avatar asked Sep 09 '26 07:09

bobfet1


1 Answers

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')
like image 94
Richard Avatar answered Sep 11 '26 20:09

Richard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!