-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_annotations.py
More file actions
42 lines (32 loc) · 1.18 KB
/
test_annotations.py
File metadata and controls
42 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see plotpy/LICENSE for details)
"""Annotation test"""
# guitest: show
from guidata.qthelpers import qt_app_context
from numpy import linspace, sin
from plotpy.builder import make
from plotpy.tests import data as ptd
from plotpy.tests import vistools as ptv
def plot(*items, plot_type="auto"):
title = "All annotation tools"
if plot_type in ("curve", "image"):
title = f"{plot_type.capitalize()} specialized plot annotation tools"
win = ptv.show_items(items, plot_type=plot_type, wintitle=title, title=title)
win.register_annotation_tools()
return win
def test_annotation():
"""Test annotation"""
x = linspace(-10, 10, 200)
y = sin(sin(sin(x)))
persist = []
with qt_app_context(exec_loop=True):
persist.append(plot(make.curve(x, y, color="b"), plot_type="curve"))
item = make.image(ptd.gen_image1())
item.set_readonly(True)
item.set_selectable(False)
persist.append(plot(item, plot_type="image"))
persist.append(plot(make.curve(x, y, color="b"), make.image(ptd.gen_image1())))
if __name__ == "__main__":
test_annotation()