Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Mayr
limbo
Commits
f589048a
Commit
f589048a
authored
Jul 05, 2017
by
Jean-Baptiste Mouret
Browse files
nicer colors in plots
parent
7b5f0ec6
Changes
1
Hide whitespace changes
Inline
Side-by-side
waf_tools/plot_bo_benchmarks.py
View file @
f589048a
...
...
@@ -4,8 +4,15 @@ from glob import glob
from
collections
import
defaultdict
import
numpy
as
np
from
pylab
import
*
import
brewer2mpl
bmap
=
brewer2mpl
.
get_map
(
'Set2'
,
'qualitative'
,
8
)
colors
=
bmap
.
mpl_colors
print
len
(
colors
)
print
colors
params
=
{
'axes.labelsize'
:
8
,
'text.fontsize'
:
8
,
...
...
@@ -34,6 +41,40 @@ def custom_ax(ax):
ax
.
get_yaxis
().
tick_left
()
ax
.
grid
(
axis
=
'x'
,
color
=
"0.9"
,
linestyle
=
'-'
)
def
custom_boxes
(
ax
,
bp
):
for
i
in
range
(
len
(
bp
[
'boxes'
])):
box
=
bp
[
'boxes'
][
i
]
box
.
set_linewidth
(
0
)
boxX
=
[]
boxY
=
[]
for
j
in
range
(
5
):
boxX
.
append
(
box
.
get_xdata
()[
j
])
boxY
.
append
(
box
.
get_ydata
()[
j
])
boxCoords
=
zip
(
boxX
,
boxY
)
boxPolygon
=
Polygon
(
boxCoords
,
facecolor
=
colors
[
i
%
len
(
colors
)],
linewidth
=
0
)
ax
.
add_patch
(
boxPolygon
)
for
i
in
range
(
0
,
len
(
bp
[
'boxes'
])):
bp
[
'boxes'
][
i
].
set_color
(
colors
[
i
])
# we have two whiskers!
bp
[
'whiskers'
][
i
*
2
].
set_color
(
colors
[
i
])
bp
[
'whiskers'
][
i
*
2
+
1
].
set_color
(
colors
[
i
])
bp
[
'whiskers'
][
i
*
2
].
set_linewidth
(
2
)
bp
[
'whiskers'
][
i
*
2
+
1
].
set_linewidth
(
2
)
# top and bottom fliers
bp
[
'fliers'
][
i
*
2
].
set
(
markerfacecolor
=
colors
[
i
],
marker
=
'o'
,
alpha
=
0.75
,
markersize
=
6
,
markeredgecolor
=
'none'
)
bp
[
'fliers'
][
i
*
2
+
1
].
set
(
markerfacecolor
=
colors
[
i
],
marker
=
'o'
,
alpha
=
0.75
,
markersize
=
6
,
markeredgecolor
=
'none'
)
bp
[
'medians'
][
i
].
set_color
(
'black'
)
bp
[
'medians'
][
i
].
set_linewidth
(
2
)
# and 4 caps to remove
for
c
in
bp
[
'caps'
]:
c
.
set_linewidth
(
0
)
# plot a single function
def
plot
(
func_name
,
data
):
d
=
data
[
func_name
]
...
...
@@ -49,12 +90,14 @@ def plot(func_name, data):
fig
.
subplots_adjust
(
left
=
0.3
)
ax
=
fig
.
add_subplot
(
121
)
custom_ax
(
ax
)
ax
.
boxplot
(
da_acc
,
0
,
'rs'
,
0
)
bp
=
ax
.
boxplot
(
da_acc
,
0
,
'rs'
,
0
)
custom_boxes
(
ax
,
bp
)
ax
.
set_yticklabels
(
labels
)
ax
.
set_title
(
"Accuracy"
)
ax
=
fig
.
add_subplot
(
122
)
custom_ax
(
ax
)
ax
.
boxplot
(
da_time
,
0
,
'rs'
,
0
)
bp
=
ax
.
boxplot
(
da_time
,
0
,
'rs'
,
0
)
custom_boxes
(
ax
,
bp
)
ax
.
set_yticklabels
([])
ax
.
set_title
(
"Wall clock time"
)
...
...
Write
Preview
Supports
Markdown
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