0

I want to try plots with pygal; however, when I do render nothing appears:

xy_chart = pygal.XY()
xy_chart.add('test', [(1,2), (2,2)])
xy_chart.render('test.svg')

Presumably, that's because the format is svg. Can I somehow save the images in standard formats or see them in python using pygal?

I tried to install dependencies for png support, but unfortunately each package requires additional installment of other packages, which eventually leads to errors.

Sergey Ivanov
  • 3,719
  • 7
  • 34
  • 59
  • What do you mean by *nothing appears*? `render` is supposed to write a file to disk. To simply view the svg file, open it with a browser. If you can't install png support directly, you can always use other software to convert the svg file to a png afterwards. – hitzg Jun 22 '15 at 13:42

1 Answers1

0

replace the last line with this:

xy_chart.render_to_file('test.svg')

render() returns a string, but it doesn't write a file directly. Try doing this to see what I mean:

svg_content = xy_chart.render()
f = open('test.svg', 'w')
print >> f, svg_content
f.close()
ate50eggs
  • 444
  • 3
  • 14