Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
apollon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Blaß, Michael
apollon
Commits
f5aa4de3
Commit
f5aa4de3
authored
Aug 1, 2020
by
Blaß, Michael
Browse files
Options
Downloads
Patches
Plain Diff
Added spine manipulation functions.
parent
ab53d252
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/apollon/aplot.py
+38
-18
38 additions, 18 deletions
src/apollon/aplot.py
with
38 additions
and
18 deletions
src/apollon/aplot.py
+
38
−
18
View file @
f5aa4de3
# Licensed under the terms of the BSD-3-Clause license.
"""
apollon/aplot.py
# Copyright (C) 2019 Michael Blaß
# mblass@posteo.net
"""
General plotting routines.
aplot.py -- General plotting routines.
Licensed under the terms of the BSD-3-Clause license.
Copyright (C) 2019 Michael Blaß
mblass@posteo.net
Functions:
Functions:
fourplot Create a four plot of time a signal.
fourplot Create a four plot of time a signal.
...
@@ -12,8 +13,7 @@ Functions:
...
@@ -12,8 +13,7 @@ Functions:
onest_decoding Plot decoded onsets over a signal.
onest_decoding Plot decoded onsets over a signal.
signal Plot a time domain signal.
signal Plot a time domain signal.
"""
"""
from
typing
import
Iterable
,
Optional
,
Tuple
,
Union
from
typing
import
Optional
,
Tuple
import
matplotlib.pyplot
as
_plt
import
matplotlib.pyplot
as
_plt
import
matplotlib.cm
as
_cm
import
matplotlib.cm
as
_cm
...
@@ -22,26 +22,29 @@ from scipy import stats as _stats
...
@@ -22,26 +22,29 @@ from scipy import stats as _stats
from
.
import
_defaults
from
.
import
_defaults
from
.
import
tools
as
_tools
from
.
import
tools
as
_tools
from
.
types
import
Array
as
_Array
from
.
types
import
Array
as
_Array
,
Axis
Limits
=
Optional
[
Tuple
[
int
,
int
]]
Limits
=
Optional
[
Tuple
[
int
,
int
]]
MplFig
=
Optional
[
_plt
.
Figure
]
MplFig
=
Optional
[
_plt
.
Figure
]
FigSize
=
Tuple
[
float
,
float
]
FigSize
=
Tuple
[
float
,
float
]
SubplotPos
=
Optional
[
Tuple
[
int
,
int
,
int
]]
SubplotPos
=
Optional
[
Tuple
[
int
,
int
,
int
]]
Axes
=
Union
[
Axis
,
Iterable
[
Axis
]]
def
_nice
_spines
(
ax
,
offset
:
in
t
=
10
)
->
None
:
def
outward
_spines
(
ax
s
:
Axes
,
offset
:
floa
t
=
10
.0
)
->
None
:
"""
Display only left and bottom spine and displace them.
"""
Display only left and bottom spine and displace them.
Note:
Increasing ``offset`` may breaks the layout. Since the spine is moved,
so is the axis label, which is in turn forced out of the figure
'
s bounds.
Args:
Args:
ax:
Ax
e
s
to be modified
.
ax
s
: Ax
i
s
or iterable of axes
.
offset: Move the spines ``offset`` pixels in the negative direction.
offset: Move the spines ``offset`` pixels in the negative direction.
Note:
Increasing ``offset`` may breaks the layout. Since the spine is moved,
so is the axis label, which is in turn forced out of the figure
'
s
bounds.
"""
"""
for
ax
in
_np
.
atleast_1d
(
axs
).
ravel
():
ax
.
spines
[
'
left
'
].
set_position
((
'
outward
'
,
offset
))
ax
.
spines
[
'
left
'
].
set_position
((
'
outward
'
,
offset
))
ax
.
spines
[
'
bottom
'
].
set_position
((
'
outward
'
,
offset
))
ax
.
spines
[
'
bottom
'
].
set_position
((
'
outward
'
,
offset
))
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
...
@@ -50,6 +53,23 @@ def _nice_spines(ax, offset: int = 10) -> None:
...
@@ -50,6 +53,23 @@ def _nice_spines(ax, offset: int = 10) -> None:
ax
.
yaxis
.
set_ticks_position
(
'
left
'
)
ax
.
yaxis
.
set_ticks_position
(
'
left
'
)
def
center_spines
(
axs
:
Axes
,
intersect
:
Tuple
[
float
,
float
]
=
(
0.0
,
0.0
))
->
None
:
"""
Display axes in crosshair fashion.
Args:
axs: Axis or iterable of axes.
intersect: Coordinate of axes
'
intersection point.
"""
for
ax
in
_np
.
atleast_1d
(
axs
).
ravel
():
ax
.
spines
[
'
left
'
].
set_position
((
'
axes
'
,
intersect
[
0
]))
ax
.
spines
[
'
bottom
'
].
set_position
((
'
axes
'
,
intersect
[
1
]))
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
ax
.
xaxis
.
set_ticks_position
(
'
bottom
'
)
ax
.
yaxis
.
set_ticks_position
(
'
left
'
)
def
_new_axis
(
spines
:
str
=
'
nice
'
,
fig
:
MplFig
=
None
,
sp_pos
:
SubplotPos
=
None
,
def
_new_axis
(
spines
:
str
=
'
nice
'
,
fig
:
MplFig
=
None
,
sp_pos
:
SubplotPos
=
None
,
axison
:
bool
=
True
,
**
kwargs
)
->
tuple
:
axison
:
bool
=
True
,
**
kwargs
)
->
tuple
:
"""
Create a new figure with a single axis and fancy spines.
"""
Create a new figure with a single axis and fancy spines.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment