Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Public
PASSOFT
SOHViewer
Commits
318d1e6a
Commit
318d1e6a
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
create function get_colors_sizes_for_abs_y_from_value_colors() to be easier in testing
parent
4a39ffe2
No related branches found
No related tags found
1 merge request
!175
correct the way to identify colors for mass pos
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sohstationviewer/view/plotting/plotting_widget/plotting.py
+6
-13
6 additions, 13 deletions
sohstationviewer/view/plotting/plotting_widget/plotting.py
sohstationviewer/view/plotting/plotting_widget/plotting_helper.py
+32
-0
32 additions, 0 deletions
...onviewer/view/plotting/plotting_widget/plotting_helper.py
with
38 additions
and
13 deletions
sohstationviewer/view/plotting/plotting_widget/plotting.py
+
6
−
13
View file @
318d1e6a
...
...
@@ -5,6 +5,9 @@ from sohstationviewer.controller.util import get_val
from
sohstationviewer.controller.plotting_data
import
get_masspos_value_colors
from
sohstationviewer.view.util.color
import
clr
from
sohstationviewer.view.plotting.plotting_widget.plotting_helper
import
(
get_colors_for_abs_y_from_value_colors
)
from
sohstationviewer.conf
import
constants
...
...
@@ -377,24 +380,14 @@ class Plotting:
self
.
plotting_axes
.
set_axes_info
(
ax
,
[
total_x
],
chan_db_info
=
chan_db_info
,
y_list
=
y_list
)
for
x
,
y
in
zip
(
x_list
,
y_list
):
# plot to have artist pl.Line2D to get pick
ax
.
myPlot
=
ax
.
plot
(
x
,
y
,
linestyle
=
'
-
'
,
linewidth
=
0.7
,
color
=
self
.
parent
.
display_color
[
'
sub_basic
'
],
picker
=
True
,
pickradius
=
3
,
zorder
=
constants
.
Z_ORDER
[
'
LINE
'
])[
0
]
colors
=
[
None
]
*
len
(
y
)
sizes
=
[
1.5
]
*
len
(
y
)
for
i
in
range
(
len
(
y
)):
count
=
-
1
for
v
,
c
in
value_colors
:
count
+=
1
if
count
<=
len
(
value_colors
)
-
2
:
if
abs
(
y
[
i
])
<=
v
:
colors
[
i
]
=
clr
[
c
]
break
else
:
# The last value color
colors
[
i
]
=
clr
[
c
]
colors
,
sizes
=
get_colors_for_abs_y_from_value_colors
(
y
,
value_colors
)
ax
.
scatter
(
x
,
y
,
marker
=
'
s
'
,
c
=
colors
,
s
=
sizes
,
zorder
=
constants
.
Z_ORDER
[
'
DOT
'
])
ax
.
x_list
=
x_list
...
...
This diff is collapsed.
Click to expand it.
sohstationviewer/view/plotting/plotting_widget/plotting_helper.py
0 → 100644
+
32
−
0
View file @
318d1e6a
from
typing
import
List
,
Tuple
from
sohstationviewer.view.util.color
import
clr
def
get_colors_sizes_for_abs_y_from_value_colors
(
y
:
List
[
float
],
value_colors
:
List
[
Tuple
[
float
,
str
]])
->
\
Tuple
[
List
[
str
],
List
[
float
]]:
"""
Map each abs(value) in y with the value in value_colors to get the colors
for the indexes corresponding to the y
'
s items.
Sizes is currently similar for all items
:param y: list of data values
:param value_colors: list of color with indexes corresponding to y
'
s items
:return colors: list of colors of markers corresponding to y
:return sizes: list of sizes of markers corresponding to y
"""
colors
=
[
None
]
*
len
(
y
)
sizes
=
[
1.5
]
*
len
(
y
)
for
i
in
range
(
len
(
y
)):
count
=
-
1
for
v
,
c
in
value_colors
:
count
+=
1
if
count
<=
len
(
value_colors
)
-
2
:
if
abs
(
y
[
i
])
<=
v
:
colors
[
i
]
=
clr
[
c
]
break
else
:
# The last value color
colors
[
i
]
=
clr
[
c
]
return
colors
,
sizes
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