Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plotter-nse
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
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
数学の武士
plotter-nse
Commits
8489d2f2
Commit
8489d2f2
authored
1 year ago
by
数学の武士
Browse files
Options
Downloads
Patches
Plain Diff
fixes
parent
18bc1ecc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/Check_plotter.ipynb
+14
-1454
14 additions, 1454 deletions
examples/Check_plotter.ipynb
plotter/Plotter.py
+85
-31
85 additions, 31 deletions
plotter/Plotter.py
plotter/__init__.py
+1
-0
1 addition, 0 deletions
plotter/__init__.py
plotter/main.py
+6
-0
6 additions, 0 deletions
plotter/main.py
with
106 additions
and
1485 deletions
examples/Check_plotter.ipynb
+
14
−
1454
View file @
8489d2f2
This diff is collapsed.
Click to expand it.
plotter/Plotter.py
+
85
−
31
View file @
8489d2f2
...
...
@@ -7,7 +7,7 @@ import natsort
import
imageio
from
.ProcData
import
ProcData
import
copy
from
matplotlib.cm
import
ScalarMappable
import
re
class
Plotter
:
ani_pngs_dir
=
"
plotter_lib_pngs/
"
...
...
@@ -55,6 +55,26 @@ class Plotter:
self
.
file_column_names
=
var_names
[
0
]
def
__set_fig_names
(
self
):
if
self
.
oname
==
None
:
self
.
fig_names
=
copy
.
deepcopy
(
self
.
var
)
self
.
fig_end
=
"
.png
"
else
:
self
.
fig_names
=
copy
.
deepcopy
(
self
.
oname
)
self
.
fig_end
=
""
special_characters
=
'
/
'
for
i
in
range
(
len
(
self
.
fig_names
)):
for
symbol
in
special_characters
:
position
=
0
while
position
<
len
(
self
.
fig_names
[
i
]):
if
self
.
fig_names
[
i
][
position
]
==
symbol
:
self
.
fig_names
[
i
]
=
self
.
fig_names
[
i
][:
position
]
+
'
\\
'
+
self
.
fig_names
[
i
][
position
+
1
:]
position
+=
2
else
:
position
+=
1
def
set
(
self
,
args
,
**
kwargs
):
self
.
__check_arg_dim_equiv
(
args
)
...
...
@@ -90,7 +110,7 @@ class Plotter:
if
args
.
func
!=
self
.
dump
:
if
args
.
func
==
self
.
plot
or
args
.
func
==
self
.
ani_plot
or
args
.
func
==
self
.
multiple_plot
:
if
args
.
func
==
self
.
plot
or
args
.
func
==
self
.
joint_plot
or
args
.
func
==
self
.
ani_plot
or
args
.
func
==
self
.
multiple_plot
:
self
.
ndim
=
1
elif
args
.
func
==
self
.
plot_contour
or
args
.
func
==
self
.
ani_plot_contour
:
self
.
ndim
=
2
...
...
@@ -102,18 +122,24 @@ class Plotter:
for
p
in
self
.
file_data
:
p
.
process_file
(
self
.
ndim
,
self
.
var
,
self
.
mval
)
self
.
fig_count
=
len
(
self
.
var
)
if
args
.
func
==
self
.
joint_plot
:
self
.
fig_count
=
len
(
self
.
file_data
)
else
:
self
.
fig_count
=
len
(
self
.
var
)
self
.
__set_fig_names
()
def
__plot
(
self
):
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
x_name
=
self
.
file_column_names
[
0
]
if
self
.
oname
==
None
:
fig_names
=
self
.
var
fig_end
=
"
.png
"
else
:
fig_names
=
self
.
oname
fig_end
=
""
#
if self.oname == None:
#
fig_names = self.var
#
fig_end = ".png"
#
else:
#
fig_names = self.oname
#
fig_end = ""
for
i
in
range
(
self
.
fig_count
):
y_name
=
self
.
var
[
i
]
...
...
@@ -125,18 +151,42 @@ class Plotter:
if
self
.
if_manual_plot
:
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
fig_names
[
i
]
+
self
.
fig_end
)
def
__joint_plot
(
self
):
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
x_name
=
self
.
file_column_names
[
0
]
# if self.oname == None:
# fig_names = self.var
# fig_end = ".png"
# else:
# fig_names = self.oname
# fig_end = ""
for
i
in
range
(
self
.
fig_count
):
fig
=
plt
.
figure
()
for
y_name
in
self
.
var
:
plt
.
plot
(
self
.
file_data
[
0
].
data
[
x_name
],
self
.
file_data
[
0
].
data
[
y_name
],
linewidth
=
4
,
label
=
y_name
)
plt
.
xlabel
(
x_name
,
fontsize
=
10
,
fontweight
=
'
bold
'
)
# plt.ylabel(y_name, fontsize=10, fontweight='bold')
plt
.
legend
()
if
self
.
if_manual_plot
:
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
fig_names
[
i
]
+
self
.
fig_end
)
def
__multiple_plot
(
self
):
os
.
system
(
"
mkdir -p
"
+
self
.
out
)
x_name
=
self
.
file_column_names
[
0
]
if
self
.
oname
==
None
:
fig_names
=
self
.
var
fig_end
=
"
.png
"
else
:
fig_names
=
self
.
oname
fig_end
=
""
#
if self.oname == None:
#
fig_names = self.var
#
fig_end = ".png"
#
else:
#
fig_names = self.oname
#
fig_end = ""
for
i
in
range
(
self
.
fig_count
):
y_name
=
self
.
var
[
i
]
...
...
@@ -151,7 +201,7 @@ class Plotter:
if
self
.
if_manual_plot
:
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
fig_names
[
i
]
+
self
.
fig_end
)
def
__get_min_max_ax
(
self
):
min_max_var_vals
=
{
var
:
[]
for
var
in
self
.
var
}
...
...
@@ -233,12 +283,12 @@ class Plotter:
x_name
=
self
.
file_column_names
[
0
]
y_name
=
self
.
file_column_names
[
1
]
if
self
.
oname
==
None
:
fig_names
=
self
.
var
fig_end
=
"
.png
"
else
:
fig_names
=
self
.
oname
fig_end
=
""
#
if self.oname == None:
#
fig_names = self.var
#
fig_end = ".png"
#
else:
#
fig_names = self.oname
#
fig_end = ""
if
self
.
max_y
==
None
:
max_val
=
{
var
:
self
.
min_max_var_vals
[
var
][
1
]
for
var
in
self
.
var
}
...
...
@@ -278,7 +328,7 @@ class Plotter:
if
self
.
if_manual_plot
:
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
fig_names
[
i
]
+
self
.
fig_end
)
def
__get_min_max_bar
(
self
):
self
.
filename
=
natsort
.
natsorted
(
self
.
filename
,
reverse
=
False
)
...
...
@@ -473,12 +523,12 @@ class Plotter:
arr
=
self
.
file_data
[
0
].
data
[
z_name
]
pos
=
self
.
__find_closest
(
arr
,
self
.
slice_position
)
if
self
.
oname
==
None
:
fig_names
=
self
.
var
fig_end
=
"
.png
"
else
:
fig_names
=
self
.
oname
fig_end
=
""
#
if self.oname == None:
#
fig_names = self.var
#
fig_end = ".png"
#
else:
#
fig_names = self.oname
#
fig_end = ""
for
i
in
range
(
self
.
fig_count
):
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
...
...
@@ -509,7 +559,7 @@ class Plotter:
if
self
.
if_manual_plot
:
plt
.
show
()
else
:
plt
.
close
(
fig
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
fig_names
[
i
]
+
fig_end
)
if
self
.
if_save_result
:
fig
.
savefig
(
self
.
out
+
self
.
fig_names
[
i
]
+
self
.
fig_end
)
def
dump
(
self
):
self
.
__dump
()
...
...
@@ -518,6 +568,10 @@ class Plotter:
self
.
__get_min_max_ax
()
self
.
__plot
()
def
joint_plot
(
self
):
self
.
__get_min_max_ax
()
self
.
__joint_plot
()
def
ani_plot
(
self
):
self
.
__get_min_max_ax
()
self
.
__ani_plot
()
...
...
This diff is collapsed.
Click to expand it.
plotter/__init__.py
+
1
−
0
View file @
8489d2f2
...
...
@@ -2,6 +2,7 @@ __version__ = "0.1.0"
from
.main
import
dump
from
.main
import
plot
from
.main
import
joint_plot
from
.main
import
ani_plot
from
.main
import
plot_contour
from
.main
import
ani_plot_contour
...
...
This diff is collapsed.
Click to expand it.
plotter/main.py
+
6
−
0
View file @
8489d2f2
...
...
@@ -20,6 +20,12 @@ def plot(filename, out = './', oname = [None], var=[None], mval=[None], min_y =
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
Plot
.
plot
()
def
joint_plot
(
filename
,
out
=
'
./
'
,
oname
=
[
None
],
var
=
[
None
],
mval
=
[
None
],
min_y
=
None
,
max_y
=
None
):
Plot
=
Plotter
()
args
=
Args
([
filename
],
Plot
.
joint_plot
,
var
=
var
,
mval
=
mval
,
oname
=
oname
,
out
=
out
)
Plot
.
set
(
args
,
if_manual_plot
=
manual_plot
,
if_save_result
=
save_result
)
Plot
.
joint_plot
()
def
multiple_plot
(
filename
,
out
=
'
./
'
,
oname
=
'
fig.png
'
,
var
=
[
None
],
mval
=
[
None
],
min_y
=
None
,
max_y
=
None
):
Plot
=
Plotter
()
args
=
Args
(
filename
,
Plot
.
multiple_plot
,
var
=
var
,
mval
=
mval
,
oname
=
oname
,
out
=
out
)
...
...
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