Reputation: 421
I have a list of tuples (x,y) of a MDS projection result and I need to show the points names/labels. So I also have a list of labels.
For instance:
labels = ['a','b','c','d']
points = [(1,2),(1,3),(1,4),(4,5)]
xy_chart = pygal.XY(stroke=False,style=LightColorizedStyle)
xy_chart.title = 'MDS projection'
xy_chart.add('Result', points)
I saw a solution using metadata and dictionary for barcharts:
chart = pygal.Bar()
chart.add('Red', [{
'value': 2,
'label': 'This is red',
'xlink': 'http://en.wikipedia.org/wiki/Red'}])
chart.add('Green', [{
'value': 4,
'label': 'This is green',
'xlink': 'http://en.wikipedia.org/wiki/Green'}])
How could I do this using scatter plot XY function from Pygal?
Upvotes: 5
Views: 2137
Reputation: 5470
You need to add a tuple for 'value'. For instance:
xy_chart = pygal.XY(stroke=False)
xy_chart.title = 'A Made Up Correlation Between Search Engines'
xy_chart.add('Group A', [{'value': (0, 0), 'label': 'google', 'xlink':'http://www.google.com'}, {'value': (22, 2), 'tooltip': 'bing', 'xlink':'http://www.bing.com'}])
xy_chart.add('Group B', [{'value': (12, 20), 'label': 'yahoo', 'xlink':'http://www.yahoo.com'}, {'value': (33, 12), 'tooltip': 'duckduckgo', 'xlink':'http://www.duckduckgo.com'}])
xy_chart.render()
Upvotes: 4