|
|
@ -103,10 +103,11 @@ class Ghost(object): |
|
|
|
with io.open(filename, 'w', encoding='utf-8') as f: |
|
|
|
with io.open(filename, 'w', encoding='utf-8') as f: |
|
|
|
f.write(self.render(is_unicode=True)) |
|
|
|
f.write(self.render(is_unicode=True)) |
|
|
|
|
|
|
|
|
|
|
|
def render_to_png(self, filename=None): |
|
|
|
def render_to_png(self, filename=None, dpi=72): |
|
|
|
"""Render the graph, convert it to png and write it to filename""" |
|
|
|
"""Render the graph, convert it to png and write it to filename""" |
|
|
|
import cairosvg |
|
|
|
import cairosvg |
|
|
|
return cairosvg.svg2png(bytestring=self.render(), write_to=filename) |
|
|
|
return cairosvg.svg2png( |
|
|
|
|
|
|
|
bytestring=self.render(), write_to=filename, dpi=dpi) |
|
|
|
|
|
|
|
|
|
|
|
def _repr_png_(self): |
|
|
|
def _repr_png_(self): |
|
|
|
"""Display png in IPython notebook""" |
|
|
|
"""Display png in IPython notebook""" |
|
|
|