Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pyLIAF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Nunez Barreto
pyLIAF
Commits
c59cdbc4
Commit
c59cdbc4
authored
Jul 14, 2021
by
Nicolas Nunez Barreto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
meto un plotxy en pyliaf para hacerle lo que querramos
parent
9626c012
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
plot_xy.py
pyLIAF/artiq/applets/plot_xy.py
+63
-0
No files found.
pyLIAF/artiq/applets/plot_xy.py
0 → 100644
View file @
c59cdbc4
#!/usr/bin/env python3
import
numpy
as
np
import
PyQt5
# make sure pyqtgraph imports Qt5
import
pyqtgraph
from
artiq.applets.simple
import
TitleApplet
class
XYPlot
(
pyqtgraph
.
PlotWidget
):
def
__init__
(
self
,
args
):
pyqtgraph
.
PlotWidget
.
__init__
(
self
)
self
.
args
=
args
def
data_changed
(
self
,
data
,
mods
,
title
):
try
:
y
=
data
[
self
.
args
.
y
][
1
]
except
KeyError
:
return
x
=
data
.
get
(
self
.
args
.
x
,
(
False
,
None
))[
1
]
if
x
is
None
:
x
=
np
.
arange
(
len
(
y
))
error
=
data
.
get
(
self
.
args
.
error
,
(
False
,
None
))[
1
]
fit
=
data
.
get
(
self
.
args
.
fit
,
(
False
,
None
))[
1
]
if
not
len
(
y
)
or
len
(
y
)
!=
len
(
x
):
return
if
error
is
not
None
and
hasattr
(
error
,
"__len__"
):
if
not
len
(
error
):
error
=
None
elif
len
(
error
)
!=
len
(
y
):
return
if
fit
is
not
None
:
if
not
len
(
fit
):
fit
=
None
elif
len
(
fit
)
!=
len
(
y
):
return
self
.
clear
()
self
.
plot
(
x
,
y
,
pen
=
None
,
symbol
=
"x"
)
self
.
setTitle
(
title
)
if
error
is
not
None
:
# See https://github.com/pyqtgraph/pyqtgraph/issues/211
if
hasattr
(
error
,
"__len__"
)
and
not
isinstance
(
error
,
np
.
ndarray
):
error
=
np
.
array
(
error
)
errbars
=
pyqtgraph
.
ErrorBarItem
(
x
=
np
.
array
(
x
),
y
=
np
.
array
(
y
),
height
=
error
)
self
.
addItem
(
errbars
)
if
fit
is
not
None
:
xi
=
np
.
argsort
(
x
)
self
.
plot
(
x
[
xi
],
fit
[
xi
])
def
main
():
applet
=
TitleApplet
(
XYPlot
)
applet
.
add_dataset
(
"y"
,
"Y values"
)
applet
.
add_dataset
(
"x"
,
"X values"
,
required
=
False
)
applet
.
add_dataset
(
"error"
,
"Error bars for each X value"
,
required
=
False
)
applet
.
add_dataset
(
"fit"
,
"Fit values for each X value"
,
required
=
False
)
applet
.
run
()
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment