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
41b61451
Commit
41b61451
authored
1 year ago
by
Michele Maris
Browse files
Options
Downloads
Patches
Plain Diff
u
parent
814a13d7
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
+41
-12
41 additions, 12 deletions
src/yapsut/graphics.py
with
41 additions
and
12 deletions
src/yapsut/graphics.py
+
41
−
12
View file @
41b61451
...
...
@@ -169,12 +169,28 @@ class StandardFig() :
"""
class to handle a Standardized Figure layout
"""
@property
def
activated
(
self
)
:
"""
True if savefig activated
"""
return
self
.
_activated
@activated.setter
def
activated
(
self
,
this
)
:
self
.
_activated
=
(
this
==
True
)
@property
def
setting
(
self
)
:
"""
name of the setting (set4slides ... )
"""
return
self
.
_setting
@property
def
figprefix
(
self
)
:
"""
Figure prefix
"""
return
self
.
_figprefix
@figprefix.setter
def
figprefix
(
self
,
this
)
:
if
this
is
None
:
self
.
_figprefix
=
""
else
:
self
.
_figprefix
=
str
(
this
).
strip
()
@property
def
figpath
(
self
)
:
"""
Figure path
"""
return
self
.
_figpath
@figpath.setter
def
figpath
(
self
,
this
)
:
...
...
@@ -191,15 +207,9 @@ class StandardFig() :
else
:
self
.
_figpath_pdf
=
self
.
_figpath
+
''
self
.
_figpath_png
=
self
.
_figpath
+
''
def
make_figpath
(
self
,
figpath
)
:
import
os
self
.
figpath
=
figpath
if
self
.
_figpath
!=
'
.
'
:
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath
)
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath_pdf
)
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath_png
)
@property
def
figratio
(
self
)
:
"""
fig ratio
"""
return
self
.
_figratio
@figratio.setter
def
figratio
(
self
,
this
)
:
...
...
@@ -209,6 +219,7 @@ class StandardFig() :
self
.
_figsize
=
(
x
,
x
*
y
)
@property
def
figside
(
self
)
:
"""
fig side
"""
return
self
.
_figside
@figside.setter
def
figside
(
self
,
this
)
:
...
...
@@ -218,6 +229,7 @@ class StandardFig() :
self
.
_figsize
=
(
x
,
x
*
y
)
@property
def
figsize
(
self
)
:
"""
fig size
"""
return
self
.
_figsize
@figsize.setter
def
figsize
(
self
,
this
)
:
...
...
@@ -246,11 +258,12 @@ class StandardFig() :
"""
dictionary of graphic objects handles
"""
return
self
.
_handle
#
def
__init__
(
self
,
figpath
=
None
,
figside
=
16
,
figratio
=
2
/
3
,
Creator
=
''
,
Copyright
=
''
,
Author
=
''
,
split_path
=
False
)
:
def
__init__
(
self
,
figpath
=
None
,
figside
=
16
,
figratio
=
2
/
3
,
Creator
=
''
,
Copyright
=
''
,
Author
=
''
,
split_path
=
False
,
figprefix
=
""
)
:
"""
Creates a StandardFig object
:Keywords:
figprefix = prefix for the figure (
""
)
figpath = path for the figure (None)
figside = horizontal side of the figure [in] (16)
figratio = V/H ratio of figure (2/3)
...
...
@@ -265,6 +278,9 @@ class StandardFig() :
#
self
.
_activated
=
True
#
self
.
_setting
=
None
#
self
.
_figprefix
=
""
self
.
_figpath
=
None
self
.
_figpath_pdf
=
None
self
.
_figpath_png
=
None
...
...
@@ -274,6 +290,8 @@ class StandardFig() :
self
.
_figratio
=
figratio
self
.
figside
=
figside
#
self
.
figprefix
=
figprefix
#
if
not
figpath
is
None
:
self
.
figpath
=
figpath
#
...
...
@@ -287,8 +305,17 @@ class StandardFig() :
self
.
setfonts4paper
()
#
self
.
legend_framealpha
=
None
def
make_figpath
(
self
,
figpath
)
:
"""
Makes figpath
"""
import
os
self
.
figpath
=
figpath
if
self
.
_figpath
!=
'
.
'
:
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath
)
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath_pdf
)
os
.
system
(
'
mkdir -p
'
+
self
.
_figpath_png
)
def
setfonts4paper
(
self
)
:
"""
sets figures with proportions for paper
"""
self
.
_setting
=
"
set4paper
"
self
.
fontsize_xylabels
=
18
self
.
fontsize_ticks
=
16
self
.
fontsize_labels
=
18
...
...
@@ -297,6 +324,7 @@ class StandardFig() :
self
.
fontsize_legend_title
=
18
def
setfonts4slides
(
self
)
:
"""
sets figures with proportions for 16:9 slides
"""
self
.
_setting
=
"
set4slides
"
self
.
fontsize_xylabels
=
32
self
.
fontsize_ticks
=
28
self
.
fontsize_labels
=
self
.
fontsize_xylabels
...
...
@@ -507,7 +535,7 @@ class StandardFig() :
,
'
Comment
'
:
self
.
Comment
}
def
__repr__
(
self
)
:
return
str
(
self
.
__class__
)
+
'
figsize:
'
+
str
(
self
.
_figsize
)
+
'
figpath:
'
+
self
.
_figpath
+
'
Creator:
'
+
self
.
Creator
+
'
activated:
'
+
str
(
self
.
activated
)
return
str
(
self
.
__class__
)
+
'
figsize:
'
+
str
(
self
.
_figsize
)
+
'
figpath:
'
+
self
.
_figpath
+
'
figprefix:
'
+
self
.
_figprefix
+
'
setting:
'
+
self
.
_setting
+
'
Creator:
'
+
self
.
Creator
+
'
activated:
'
+
str
(
self
.
activated
)
def
save
(
self
,
name
,
Author
=
None
,
Comment
=
None
...
...
@@ -539,12 +567,13 @@ class StandardFig() :
self
.
Title
=
name
#
metadata
=
None
Name
=
self
.
figprefix
+
name
if
k
==
'
pdf
'
:
metadata
=
self
.
pdf_metadata
oname
=
self
.
_figpath_pdf
+
'
/
'
+
n
ame
+
'
.pdf
'
oname
=
self
.
_figpath_pdf
+
'
/
'
+
N
ame
+
'
.pdf
'
if
k
==
'
png
'
:
metadata
=
self
.
png_metadata
oname
=
self
.
_figpath_png
+
'
/
'
+
n
ame
+
'
.png
'
oname
=
self
.
_figpath_png
+
'
/
'
+
N
ame
+
'
.png
'
print
(
'
savefig
'
,
oname
)
#
plt
.
savefig
(
oname
,
dpi
=
plt
.
gcf
().
get_dpi
(),
metadata
=
metadata
)
...
...
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