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
32286888
Commit
32286888
authored
1 year ago
by
Michele Maris
Browse files
Options
Downloads
Patches
Plain Diff
u
parent
3f5e2dc7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/yapsut/AppendableDict.py
+9
-13
9 additions, 13 deletions
src/yapsut/AppendableDict.py
src/yapsut/graphics.py
+63
-10
63 additions, 10 deletions
src/yapsut/graphics.py
with
72 additions
and
23 deletions
src/yapsut/AppendableDict.py
+
9
−
13
View file @
32286888
...
...
@@ -7,19 +7,15 @@ import time
class
AppendableDict
:
"""
a dictionary, whose arguments are lists which can be appended
Example:
>AD=AppendableDict()
>
>AD[
'
line1
'
]=1
>AD[
'
line2
'
]=10
>
>AD[
'
line1
'
]=2
>AD[
'
line2
'
]=20
>
>AD[
'
line1
'
]=3
>AD[
'
line2
'
]=30
>
>print(AD[
'
line1
'
])
Examples:
>>>AD=AppendableDict()
>>>AD[
'
line1
'
]=1
>>>AD[
'
line2
'
]=10
>>>AD[
'
line1
'
]=2
>>>AD[
'
line2
'
]=20
>>>AD[
'
line1
'
]=3
>>>AD[
'
line2
'
]=30
>>>print(AD[
'
line1
'
])
[1,2,3]
"""
...
...
This diff is collapsed.
Click to expand it.
src/yapsut/graphics.py
+
63
−
10
View file @
32286888
...
...
@@ -204,7 +204,34 @@ class StandardFig() :
def
split_path_setter
(
self
,
this
)
:
self
.
_split_path
=
(
this
==
True
)
#
@property
def
fig
(
self
)
:
"""
handle for fig
"""
try
:
return
self
.
_handle
[
'
fig
'
]
except
:
return
None
#
@property
def
handle
(
self
)
:
"""
dictionary of graphic objects handles
"""
return
self
.
_handle
#
def
__init__
(
self
,
figpath
=
None
,
figside
=
16
,
figratio
=
2
/
3
,
Creator
=
''
,
Copyright
=
''
,
Author
=
''
,
split_path
=
False
)
:
"""
Creates a StandardFig object
:Keywords:
figpath = path for the figure (None)
figside = horizontal side of the figure [in] (16)
figratio = V/H ratio of figure (2/3)
split_path = if True the path is splitted (False)
Creator = creator
Author = Author Name
Copyright = copyright string
To have the handles to the figure components use the .handle dictionary.
"""
self
.
free_metadata
()
#
self
.
_activated
=
True
...
...
@@ -225,13 +252,17 @@ class StandardFig() :
self
.
Creator
=
Creator
self
.
Copyright
=
Copyright
#
self
.
fig
=
None
# list of handles for various objects
self
.
_handle
=
{}
#
self
.
fontsize_ticks
=
16
self
.
fontsize_labels
=
18
self
.
fontsize_xylabels
=
18
self
.
fontsize_title
=
18
self
.
fontsize_legend
=
18
self
.
fontsize_legend_title
=
18
#
self
.
legend_framealpha
=
None
def
copy
(
self
)
:
import
copy
return
self
.
deepcopy
(
self
)
...
...
@@ -239,34 +270,56 @@ class StandardFig() :
return
self
.
new
(
squared
=
squared
)
def
new
(
self
,
squared
=
False
)
:
from
matplotlib
import
pyplot
as
plt
self
.
_handle
=
{}
if
squared
:
self
.
fig
=
plt
.
figure
(
figsize
=
(
self
.
figside
,
self
.
figside
));
self
.
_handle
[
'
fig
'
]
=
plt
.
figure
(
figsize
=
(
self
.
figside
,
self
.
figside
));
else
:
self
.
fig
=
plt
.
figure
(
figsize
=
self
.
figsize
);
self
.
_handle
[
'
fig
'
]
=
plt
.
figure
(
figsize
=
self
.
figsize
);
self
.
fig
.
canvas
.
toolbar_visible
=
True
self
.
fig
.
canvas
.
header_visible
=
False
self
.
fig
.
canvas
.
resizable
=
True
return
self
.
fig
def
legend
(
self
,
ncol
=
1
,
loc
=
1
,
title
=
''
,
fontsize
=
None
)
:
def
legend
(
self
,
ncol
=
1
,
loc
=
1
,
title
=
''
,
fontsize
=
None
,
ax
=
None
,
title_fontsize
=
None
,
LISTP
=
None
,
legend_framealpha
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_legend
if
fontsize
is
None
else
fontsize
return
plt
.
legend
(
ncol
=
ncol
,
loc
=
loc
,
fontsize
=
fs
,
title
=
title
)
fsl
=
self
.
fontsize_legend
if
fontsize
is
None
else
fontsize
fslt
=
self
.
fontsize_legend_title
if
title_fontsize
is
None
else
title_fontsize
falpha
=
self
.
legend_framealpha
if
legend_framealpha
is
None
else
legend_framealpha
self
.
ax_legend
=
None
ax1
=
plt
.
gca
()
if
ax
==
None
else
ax
#
if
LISTP
==
None
:
self
.
_handle
[
'
legend
'
]
=
ax1
.
legend
(
ncol
=
ncol
,
loc
=
loc
,
fontsize
=
fsl
,
title
=
title
,
title_fontsize
=
fslt
)
return
self
.
_handle
[
'
legend
'
]
#
lns
=
LISTP
[
0
]
for
ik
in
range
(
len
(
LISTP
))
:
if
ik
==
0
:
lns
=
LISTP
[
0
]
else
:
lns
+=
LISTP
[
ik
]
labs
=
[
l
.
get_label
()
for
l
in
lns
]
self
.
_handle
[
'
legend
'
]
=
ax1
.
legend
(
lns
,
labs
,
ncol
=
ncol
,
loc
=
loc
,
fontsize
=
self
.
fontsize_legend
if
fontsize
is
None
else
fontsize
,
title
=
title
,
title_fontsize
=
fslt
)
return
self
.
_handle
[
'
legend
'
]
def
title
(
self
,
txt
,
fontsize
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_title
if
fontsize
is
None
else
fontsize
return
plt
.
title
(
txt
,
fontsize
=
fs
)
self
.
_handle
[
'
title
'
]
=
plt
.
title
(
txt
,
fontsize
=
fs
)
return
self
.
_handle
[
'
title
'
]
def
suptitle
(
self
,
txt
,
fontsize
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_title
if
fontsize
is
None
else
fontsize
return
plt
.
suptitle
(
txt
,
fontsize
=
fs
)
self
.
_handle
[
'
suptitle
'
]
=
plt
.
suptitle
(
txt
,
fontsize
=
fs
)
return
self
.
_handle
[
'
suptitle
'
]
def
xlabel
(
self
,
txt
,
fontsize
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_xylabels
if
fontsize
is
None
else
fontsize
return
plt
.
xlabel
(
txt
,
fontsize
=
fs
)
self
.
_handle
[
'
xlabel
'
]
=
plt
.
xlabel
(
txt
,
fontsize
=
fs
)
return
self
.
_handle
[
'
xlabel
'
]
def
ylabel
(
self
,
txt
,
fontsize
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_xylabels
if
fontsize
is
None
else
fontsize
return
plt
.
ylabel
(
txt
,
fontsize
=
fs
)
self
.
_handle
[
'
ylabel
'
]
=
plt
.
ylabel
(
txt
,
fontsize
=
fs
)
return
self
.
_handle
[
'
ylabel
'
]
def
XTICKS
(
self
,
ax
=
None
,
fontsize
=
None
)
:
from
matplotlib
import
pyplot
as
plt
fs
=
self
.
fontsize_ticks
if
fontsize
is
None
else
fontsize
...
...
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