Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
YAPSUT
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
Michele Maris
YAPSUT
Commits
c24a25b5
Commit
c24a25b5
authored
1 year ago
by
Michele Maris
Browse files
Options
Downloads
Patches
Plain Diff
u
parent
41b61451
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/yapsut/graphics.py
+56
-0
56 additions, 0 deletions
src/yapsut/graphics.py
with
56 additions
and
0 deletions
src/yapsut/graphics.py
+
56
−
0
View file @
c24a25b5
import
matplotlib.pyplot
as
plt
import
numpy
as
np
class
ImshowXT
:
"""
class to handle an improved version of plt.imshow
"""
def
__init__
(
self
,
matr
,
x_values
,
y_values
,
**
kwargs
)
:
"""
matr = the matrix to show,
x_values = the values on the x axis,
y_values, the values on the y axis
kwarg = kwargs for plt.imshow
"""
from
matplotlib
import
pyplot
as
plt
self
.
_im
=
plt
.
imshow
(
matr
,
**
kwargs
)
self
.
_xv
=
x_values
self
.
_yv
=
y_values
def
set_xaxis
(
self
,
major_values
,
major_format
)
:
"""
format the x axis for a give list of tick values and a formatting string
"""
from
matplotlib
import
pyplot
as
plt
import
numpy
as
np
self
.
_mxv
=
major_values
self
.
_mxf
=
major_format
#
v
=
self
.
_xv
t
=
np
.
array
([
np
.
argmin
(
np
.
abs
(
k
-
v
))
for
k
in
major_values
])
t1
=
np
.
arange
(
len
(
v
))
#
plt
.
xticks
(
t
,
np
.
interp
(
t
,
t1
,
v
))
tt
=
plt
.
gca
().
get_xticklabels
()
for
ik
in
range
(
len
(
tt
))
:
o
=
float
(
tt
[
ik
].
get_text
())
o1
=
major_format
%
o
tt
[
ik
].
set_text
(
o1
)
plt
.
gca
().
set_xticklabels
(
tt
)
def
set_yaxis
(
self
,
major_values
,
major_format
)
:
"""
format the y axis for a give list of tick values and a formatting string
"""
from
matplotlib
import
pyplot
as
plt
import
numpy
as
np
self
.
_myv
=
major_values
self
.
_myf
=
major_format
#
v
=
self
.
_yv
t
=
np
.
array
([
np
.
argmin
(
np
.
abs
(
k
-
v
))
for
k
in
major_values
])
t1
=
np
.
arange
(
len
(
v
))
#
plt
.
yticks
(
t
,
np
.
interp
(
t
,
t1
,
v
))
tt
=
plt
.
gca
().
get_yticklabels
()
for
ik
in
range
(
len
(
tt
))
:
o
=
float
(
tt
[
ik
].
get_text
())
o1
=
major_format
%
o
tt
[
ik
].
set_text
(
o1
)
plt
.
gca
().
set_yticklabels
(
tt
)
def
colorbar
(
self
,
**
karg
)
:
"""
add a color bar
"""
from
matplotlib
import
pyplot
as
plt
plt
.
colorbar
(
**
karg
)
def
odot
(
x
,
y
,
color
=
[
'
yellow
'
,
'
red
'
],
markersize
=
[
30
,
10
],
scale
=
1.
,
zorder
=
None
,
mew
=
[
4
,
0
])
:
def
odot
(
x
,
y
,
color
=
[
'
yellow
'
,
'
red
'
],
markersize
=
[
30
,
10
],
scale
=
1.
,
zorder
=
None
,
mew
=
[
4
,
0
])
:
"""
draw an odot
"""
"""
draw an odot
"""
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
...
...
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