Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
e2ab89d8
Commit
e2ab89d8
authored
Dec 17, 2013
by
panos
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insert comments on Plots script
parent
bb1bd489
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
dream/simulation/outputanalysis/Plots.py
dream/simulation/outputanalysis/Plots.py
+19
-16
No files found.
dream/simulation/outputanalysis/Plots.py
View file @
e2ab89d8
...
...
@@ -24,20 +24,23 @@ Created on 16 Dec 2013
'''
from
rpy2
import
robjects
#The Graphs object
class
Graphs
:
#Graphs that can visualize the data samples
def
Plots
(
self
,
data
,
fileName
=
"plotChart.jpg"
):
data
=
robjects
.
FloatVector
(
data
)
rplot
=
robjects
.
r
[
'plot'
]
rdev
=
robjects
.
r
[
'dev.off'
]
rjpeg
=
robjects
.
r
[
'jpeg'
]
data
=
robjects
.
FloatVector
(
data
)
#The given list changes into float vector in order to be handled by RPy2
rplot
=
robjects
.
r
[
'plot'
]
#Call plot function - R function
rdev
=
robjects
.
r
[
'dev.off'
]
#Call dev.off - R function
rjpeg
=
robjects
.
r
[
'jpeg'
]
#Call jpeg - R function
output
=
rjpeg
(
fileName
)
rplot
(
data
,
type
=
"o"
,
col
=
"blue"
)
output
=
rjpeg
(
fileName
)
#output the plot (jpeg file format) in the given directory
rplot
(
data
,
type
=
"o"
,
col
=
"blue"
)
#Graph data sample and define color and type for the data points visualization
rdev
return
output
def
ScatterPlot
(
self
,
data1
,
data2
,
fileName
=
"scatterplot.jpg"
):
#The given lists change into float vector in order to be handled by RPy2
data1
=
robjects
.
FloatVector
(
data1
)
data2
=
robjects
.
FloatVector
(
data2
)
...
...
@@ -45,34 +48,34 @@ class Graphs:
rdev
=
robjects
.
r
[
'dev.off'
]
rjpeg
=
robjects
.
r
[
'jpeg'
]
output
=
rjpeg
(
fileName
)
output
=
rjpeg
(
fileName
)
#Graph data samples and define color and type for the data points visualization
rplot
(
data1
,
data2
,
type
=
"o"
,
col
=
"red"
)
rdev
return
output
def
Pie
(
self
,
data1
,
fileName
=
"pieChart.jpg"
):
data1
=
robjects
.
FloatVector
(
data1
)
rpaste
=
robjects
.
r
[
'paste'
]
rround
=
robjects
.
r
[
'round'
]
rsum
=
robjects
.
r
[
'sum'
]
rpie
=
robjects
.
r
[
'pie'
]
data1
=
robjects
.
FloatVector
(
data1
)
#The given list changes into float vector in order to be handled by RPy2
rpaste
=
robjects
.
r
[
'paste'
]
#Call paste - R function
rround
=
robjects
.
r
[
'round'
]
#Call round - R function
rsum
=
robjects
.
r
[
'sum'
]
#Call sum - R function
rpie
=
robjects
.
r
[
'pie'
]
#Call pie - R function
rdev
=
robjects
.
r
[
'dev.off'
]
colors
=
robjects
.
StrVector
([
"white"
,
"grey70"
,
"grey90"
,
"grey50"
,
"grey60"
,
"black"
])
colors
=
robjects
.
StrVector
([
"white"
,
"grey70"
,
"grey90"
,
"grey50"
,
"grey60"
,
"black"
])
#Define colors to be used for black&white print
s
=
rsum
(
data1
)
d_labels
=
[
0
]
*
(
len
(
data1
))
i
=
0
while
i
<
len
(
data1
):
d_labels
[
i
]
=
((
rround
((
data1
[
i
]
/
s
[
0
])
*
100
,
1
)))
d_labels
[
i
]
=
((
rround
((
data1
[
i
]
/
s
[
0
])
*
100
,
1
)))
#Calculate the percentage for each data point, rounded to one decimal place
i
+=
1
d_labels
=
rpaste
(
d_labels
,
"%"
,
sep
=
""
)
d_labels
=
rpaste
(
d_labels
,
"%"
,
sep
=
""
)
#Concatenate a "%" car after each value
rjpeg
=
robjects
.
r
[
'jpeg'
]
export
=
rjpeg
(
fileName
)
rpie
(
data1
,
main
=
"Data"
,
col
=
colors
,
labels
=
d_labels
,
cex
=
0.8
)
rpie
(
data1
,
main
=
"Data"
,
col
=
colors
,
labels
=
d_labels
,
cex
=
0.8
)
#Create a pie chart with defined heading and custom colors
rdev
return
export
...
...
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