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
FSL
fsleyes
fsleyes-widgets
Commits
cbec11f1
Commit
cbec11f1
authored
May 11, 2018
by
Paul McCarthy
🚵
Browse files
ENH: colourBarBitmap accepts a scale parameter, allowing DPI to be
changed. Useful for high-DPI displays.
parent
96ad0266
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsleyes_widgets/utils/colourbarbitmap.py
View file @
cbec11f1
...
...
@@ -27,7 +27,8 @@ def colourBarBitmap(cmap,
alpha
=
1.0
,
fontsize
=
10
,
bgColour
=
None
,
textColour
=
'#ffffff'
):
textColour
=
'#ffffff'
,
scale
=
1.0
):
"""Plots a colour bar using :mod:`matplotlib`.
...
...
@@ -83,6 +84,8 @@ def colourBarBitmap(cmap,
:arg textColour: Label colour - can be any colour specification that
is accepted by :mod:`matplotlib`.
:arg scale: DPI scaling factor.
"""
# These imports are expensive, so we're
...
...
@@ -113,18 +116,21 @@ def colourBarBitmap(cmap,
if
labelside
==
'left'
:
labelside
=
'top'
else
:
labelside
=
'bottom'
dpi
=
96.0
ncols
=
cmapResolution
data
=
genColours
(
cmap
,
ncols
,
invert
,
alpha
,
gamma
)
# Default is 96 dpi to an inch
winches
=
width
/
96.0
hinches
=
height
/
96.0
dpi
=
scale
*
96.0
ncols
=
cmapResolution
data
=
genColours
(
cmap
,
ncols
,
invert
,
alpha
,
gamma
)
if
negCmap
is
not
None
:
ndata
=
genColours
(
negCmap
,
ncols
,
not
invert
,
alpha
,
gamma
)
data
=
np
.
concatenate
((
ndata
,
data
),
axis
=
1
)
ncols
*=
2
fig
=
mplfig
.
Figure
(
figsize
=
(
wi
dth
/
dpi
,
height
/
dpi
),
dpi
=
dpi
)
canvas
=
mplagg
.
FigureCanvasAgg
(
fig
)
ax
=
fig
.
add_subplot
(
111
)
fig
=
mplfig
.
Figure
(
figsize
=
(
wi
nches
,
hinches
),
dpi
=
dpi
)
canvas
=
mplagg
.
FigureCanvasAgg
(
fig
)
ax
=
fig
.
add_subplot
(
111
)
if
bgColour
is
not
None
:
fig
.
patch
.
set_facecolor
(
bgColour
)
...
...
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