Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-spectrometer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QuTech
python-spectrometer
Commits
a82bc092
Verified
Commit
a82bc092
authored
6 months ago
by
Tobias Hangleiter
Browse files
Options
Downloads
Patches
Plain Diff
Make figure identifier unique
parent
e261d03f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!60
Improve responsiveness during acquisition
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python_spectrometer/_plot_manager.py
+9
-1
9 additions, 1 deletion
src/python_spectrometer/_plot_manager.py
with
9 additions
and
1 deletion
src/python_spectrometer/_plot_manager.py
+
9
−
1
View file @
a82bc092
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
contextlib
import
contextlib
import
os
import
os
import
warnings
import
warnings
import
weakref
from
itertools
import
compress
from
itertools
import
compress
from
typing
import
Dict
,
Any
,
Optional
,
Mapping
,
Tuple
,
ContextManager
,
Iterable
,
Union
,
List
from
typing
import
Dict
,
Any
,
Optional
,
Mapping
,
Tuple
,
ContextManager
,
Iterable
,
Union
,
List
...
@@ -18,6 +19,8 @@ _styleT = Union[None, _styleT, List[_styleT]]
...
@@ -18,6 +19,8 @@ _styleT = Union[None, _styleT, List[_styleT]]
class
PlotManager
:
class
PlotManager
:
__instances
=
weakref
.
WeakSet
()
# TODO: blit?
# TODO: blit?
PLOT_TYPES
=
(
'
main
'
,
'
cumulative
'
,
'
time
'
)
PLOT_TYPES
=
(
'
main
'
,
'
cumulative
'
,
'
time
'
)
LINE_TYPES
=
(
'
processed
'
,
'
raw
'
)
LINE_TYPES
=
(
'
processed
'
,
'
raw
'
)
...
@@ -68,7 +71,7 @@ class PlotManager:
...
@@ -68,7 +71,7 @@ class PlotManager:
self
.
legend_kw
=
legend_kw
or
dict
()
self
.
legend_kw
=
legend_kw
or
dict
()
self
.
legend_kw
.
setdefault
(
'
loc
'
,
'
upper right
'
)
self
.
legend_kw
.
setdefault
(
'
loc
'
,
'
upper right
'
)
self
.
figure_kw
.
setdefault
(
'
num
'
,
'
Spectrometer
'
)
self
.
figure_kw
.
setdefault
(
'
num
'
,
f
'
Spectrometer
{
len
(
self
.
__instances
)
+
1
}
'
)
if
not
any
(
'
layout
'
in
key
for
key
in
self
.
figure_kw
.
keys
()):
if
not
any
(
'
layout
'
in
key
for
key
in
self
.
figure_kw
.
keys
()):
# depending on the matplotlib version, this setting is either
# depending on the matplotlib version, this setting is either
# layout='tight' or tight_layout=True
# layout='tight' or tight_layout=True
...
@@ -76,6 +79,11 @@ class PlotManager:
...
@@ -76,6 +79,11 @@ class PlotManager:
if
self
.
subplot_kw
.
pop
(
'
sharex
'
,
None
)
is
not
None
:
if
self
.
subplot_kw
.
pop
(
'
sharex
'
,
None
)
is
not
None
:
warnings
.
warn
(
'
sharex in subplot_kw not negotiable, dropping
'
,
UserWarning
)
warnings
.
warn
(
'
sharex in subplot_kw not negotiable, dropping
'
,
UserWarning
)
# Keep track of instances that are alive for figure counting
self
.
__instances
.
add
(
self
)
# TODO: this somehow never executes
weakref
.
finalize
(
self
,
self
.
__instances
.
discard
,
self
)
def
is_fig_open
(
self
)
->
bool
:
def
is_fig_open
(
self
)
->
bool
:
"""
Is the figure currently open, pending all events?
"""
"""
Is the figure currently open, pending all events?
"""
# Need to flush possible close events before we can be sure!
# Need to flush possible close events before we can be sure!
...
...
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