Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tfields
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Boeckenhoff
tfields
Commits
e0527b47
Commit
e0527b47
authored
6 years ago
by
Daniel Boeckenhoff
Browse files
Options
Downloads
Patches
Plain Diff
mpl set_legend
parent
bacad5bf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tfields/lib/util.py
+16
-1
16 additions, 1 deletion
tfields/lib/util.py
tfields/plotting/mpl.py
+21
-0
21 additions, 0 deletions
tfields/plotting/mpl.py
tfields/plotting/tfields.mplstyle
+1
-6
1 addition, 6 deletions
tfields/plotting/tfields.mplstyle
with
38 additions
and
7 deletions
tfields/lib/util.py
+
16
−
1
View file @
e0527b47
...
...
@@ -67,6 +67,7 @@ def multi_sort(array, *others, **kwargs):
method (function): sorting function. Default is
'
sorted
'
...
:
further
arguments
are
passed
to
method
.
Default
rest
is
'
key=array[0]
'
reversed
(
bool
):
wether
to
reverse
the
results
or
not
Examples
:
>>>
from
tfields.lib.util
import
multi_sort
>>>
multi_sort
([
1
,
2
,
3
,
6
,
4
],
[
1
,
2
,
3
,
4
,
5
])
...
...
@@ -79,10 +80,24 @@ def multi_sort(array, *others, **kwargs):
>>>
multi_sort
([
1
,
2
,
3
,
6
,
4
],
[
1
,
2
,
3
,
4
,
5
],
[
6
,
5
,
4
,
3
,
2
])
[[
1
,
2
,
3
,
4
,
6
],
[
1
,
2
,
3
,
5
,
4
],
[
6
,
5
,
4
,
2
,
3
]]
Reverse argument
>>>
multi_sort
([
1
,
2
,
3
,
6
,
4
],
[
1
,
2
,
3
,
4
,
5
],
[
6
,
5
,
4
,
3
,
2
],
reverse
=
True
)
[[
6
,
4
,
3
,
2
,
1
],
[
4
,
5
,
3
,
2
,
1
],
[
3
,
2
,
4
,
5
,
6
]]
"""
method
=
kwargs
.
pop
(
'
method
'
,
None
)
if
method
is
None
:
method
=
sorted
if
'
key
'
not
in
kwargs
:
kwargs
[
'
key
'
]
=
lambda
pair
:
pair
[
0
]
return
[
list
(
x
)
for
x
in
zip
(
*
method
(
zip
(
array
,
*
others
),
**
kwargs
))]
reverse
=
kwargs
.
pop
(
'
reverse
'
,
False
)
if
not
reverse
:
cast_type
=
list
else
:
cast_type
=
lambda
x
:
list
(
reversed
(
x
))
return
[
cast_type
(
x
)
for
x
in
zip
(
*
method
(
zip
(
array
,
*
others
),
**
kwargs
))]
if
__name__
==
'
__main__
'
:
import
doctest
doctest
.
testmod
()
This diff is collapsed.
Click to expand it.
tfields/plotting/mpl.py
+
21
−
0
View file @
e0527b47
...
...
@@ -697,9 +697,30 @@ def set_legend(axis, artists, **kwargs):
for
artist
in
artists
:
if
isinstance
(
artist
,
list
):
handles
.
append
(
artist
[
0
])
elif
isinstance
(
artist
,
tuple
):
tuple_handle
=
tuple
()
for
sub_artist
in
artist
:
if
isinstance
(
sub_artist
,
list
):
tuple_handle
+=
(
sub_artist
[
0
],)
else
:
tuple_handle
+=
(
sub_artist
,)
handles
.
append
(
tuple_handle
)
else
:
handles
.
append
(
artist
)
if
labels
is
None
and
any
([
isinstance
(
h
,
tuple
)
for
h
in
handles
]):
labels
=
[]
for
h
in
handles
:
if
isinstance
(
h
,
tuple
):
sub_labels
=
[
sub_h
.
get_label
()
for
sub_h
in
h
]
label
=
sub_labels
[
0
]
for
sub_label
in
sub_labels
[
1
:]:
if
not
sub_label
.
startswith
(
'
_
'
):
label
+=
sub_label
else
:
label
=
h
.
get_label
()
labels
.
append
(
label
)
if
table
and
labels
is
None
and
ncol
is
None
:
table_title
=
kwargs
.
pop
(
'
table_title
'
,
''
)
labels
=
np
.
array
([
h
.
get_label
()
for
h
in
handles
])
...
...
This diff is collapsed.
Click to expand it.
tfields/plotting/tfields.mplstyle
+
1
−
6
View file @
e0527b47
...
...
@@ -35,9 +35,4 @@ image.cmap: viridis
text.usetex : True
font.family : serif
font.size : 40 # 20 was a duplicate definition
# mathtext.fontset = 'custom'
# mathtext.rm = 'Bitstream Vera Sans'
# mathtext.it = 'Bitstream Vera Sans:italic'
# mathtext.bf = 'Bitstream Vera Sans:bold'
# mathtext.fontset = 'stix'
# font.family = 'STIXGeneral'
text.latex.preamble : \usepackage{amsmath} # for \text etc
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