Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
fb361c97
Commit
fb361c97
authored
Feb 28, 2015
by
LE GAC Renaud
Browse files
Add logic to save graph in pdf or png format.
parent
f56eec5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
modules/report_objects.py
modules/report_objects.py
+24
-13
No files found.
modules/report_objects.py
View file @
fb361c97
...
...
@@ -294,13 +294,33 @@ class Graph(BaseReport):
ax
.
tick_params
(
which
=
'minor'
,
length
=
4
)
def
_savefig
(
self
,
format
):
"""Save the figure as a string.
@type format: str
@param format: possible values are pdf, png and svg.
"""
fig
=
self
.
ax
.
get_figure
()
fi
=
StringIO
()
fig
.
savefig
(
fi
,
format
=
format
)
data
=
fi
.
getvalue
()
fi
.
close
()
fig
.
clear
()
matplotlib
.
pyplot
.
close
(
fig
)
return
data
def
to_pdf
(
self
):
"""
@rtype: string
@return: encode the graph with the PDF format.
"""
return
self
.
_savefig
(
'pdf'
)
def
to_png
(
self
):
"""
...
...
@@ -308,7 +328,8 @@ class Graph(BaseReport):
@return: encode the graph with the PNG format.
"""
return
self
.
_savefig
(
'png'
)
def
to_svg
(
self
):
"""
...
...
@@ -316,17 +337,7 @@ class Graph(BaseReport):
@return: encode the graph with the SVG format.
"""
fig
=
self
.
ax
.
get_figure
()
fi
=
StringIO
()
fig
.
savefig
(
fi
,
format
=
'svg'
)
data
=
fi
.
getvalue
()
fi
.
close
()
fig
.
clear
()
matplotlib
.
pyplot
.
close
(
fig
)
return
data
return
self
.
_savefig
(
'svg'
)
class
List
(
BaseReport
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment