tikzplotly 0.1.5__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/PKG-INFO +4 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/README.md +3 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/pyproject.toml +1 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tests/test_heatmaps.py +9 -13
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tests/test_markers.py +0 -1
- tikzplotly-0.1.7/src/tikzplotly/__about__.py +1 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_heatmap.py +2 -2
- tikzplotly-0.1.7/src/tikzplotly/_marker.py +228 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_save.py +24 -4
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/PKG-INFO +4 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/SOURCES.txt +5 -1
- tikzplotly-0.1.7/tests/test_heatmap.py +74 -0
- tikzplotly-0.1.7/tests/test_markers.py +92 -0
- tikzplotly-0.1.7/tests/test_scatter.py +163 -0
- tikzplotly-0.1.7/tests/test_tikzplotly.py +6 -0
- tikzplotly-0.1.5/src/tikzplotly/__about__.py +0 -1
- tikzplotly-0.1.5/src/tikzplotly/_marker.py +0 -121
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/LICENSE +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/setup.cfg +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tests/test_line_charts.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/__init__.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_annotations.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_axis.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_color.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_dash.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_data.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_dataContainer.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_scatter.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_tex.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly/_utils.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/dependency_links.txt +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/requires.txt +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tikzplotly
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Convert plotly figures to LaTeX / tikz figures
|
|
5
5
|
Author-email: Thomas Saigre <tikzplotly@outlook.fr>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -30,7 +30,6 @@ Keywords: plotly,latex,tikz,figure,conversion,graphics
|
|
|
30
30
|
Classifier: Development Status :: 5 - Production/Stable
|
|
31
31
|
Classifier: Programming Language :: Python
|
|
32
32
|
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
34
33
|
Classifier: Programming Language :: Python :: 3.8
|
|
35
34
|
Classifier: Programming Language :: Python :: 3.9
|
|
36
35
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -52,6 +51,9 @@ Requires-Dist: pandas; extra == "dev"
|
|
|
52
51
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
53
52
|
|
|
54
53
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
54
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
55
|
+

|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
# Tikzplotly
|
|
57
59
|
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
5
5
|
|
|
6
6
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
7
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
8
|
+

|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
# Tikzplotly
|
|
9
12
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tikzplotly"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.7"
|
|
8
8
|
description = "Convert plotly figures to LaTeX / tikz figures"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{name = "Thomas Saigre", email = "tikzplotly@outlook.fr"}]
|
|
@@ -13,7 +13,6 @@ classifiers = [
|
|
|
13
13
|
"Development Status :: 5 - Production/Stable",
|
|
14
14
|
"Programming Language :: Python",
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
|
-
"Programming Language :: Python :: 3.7",
|
|
17
16
|
"Programming Language :: Python :: 3.8",
|
|
18
17
|
"Programming Language :: Python :: 3.9",
|
|
19
18
|
"Programming Language :: Python :: 3.10",
|
|
@@ -6,11 +6,9 @@ from tikzplotly._tex import tex_create_document, tex_begin_environment, tex_end_
|
|
|
6
6
|
|
|
7
7
|
import plotly
|
|
8
8
|
import plotly.express as px
|
|
9
|
-
import pandas as pd
|
|
10
9
|
import plotly.graph_objects as go
|
|
11
10
|
import numpy as np
|
|
12
11
|
import datetime
|
|
13
|
-
import numpy as np
|
|
14
12
|
np.random.seed(1)
|
|
15
13
|
|
|
16
14
|
def fig1():
|
|
@@ -168,17 +166,16 @@ if __name__ == "__main__":
|
|
|
168
166
|
file_directory = os.path.dirname(os.path.abspath(__file__))
|
|
169
167
|
|
|
170
168
|
functions = [
|
|
171
|
-
("1", fig1),
|
|
172
|
-
("2", fig2),
|
|
173
|
-
# ("3", fig3), # texttemplate not supported
|
|
174
|
-
("4", fig4),
|
|
175
|
-
("5", fig5),
|
|
176
|
-
("6", fig6),
|
|
169
|
+
# ("1", fig1),
|
|
170
|
+
# ("2", fig2),
|
|
171
|
+
# # ("3", fig3), # texttemplate not supported
|
|
172
|
+
# ("4", fig4),
|
|
173
|
+
# ("5", fig5),
|
|
174
|
+
# ("6", fig6),
|
|
177
175
|
("7", fig7),
|
|
178
|
-
# ("8", fig8), # Not supported
|
|
179
|
-
("9", fig9),
|
|
180
|
-
("11", fig11)
|
|
181
|
-
|
|
176
|
+
# # ("8", fig8), # Not supported
|
|
177
|
+
# ("9", fig9),
|
|
178
|
+
# ("11", fig11)
|
|
182
179
|
]
|
|
183
180
|
|
|
184
181
|
main_tex_content = tex_create_document(options="twocolumn", compatibility="newest")
|
|
@@ -190,7 +187,6 @@ if __name__ == "__main__":
|
|
|
190
187
|
for i, f in functions:
|
|
191
188
|
print(f"Figure {i}")
|
|
192
189
|
fig, title = f()
|
|
193
|
-
data = fig.data
|
|
194
190
|
save_path = os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.tex".format(i))
|
|
195
191
|
tikzplotly.save(save_path, fig, img_name=os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.png".format(i)))
|
|
196
192
|
main_tex_content += tex_begin_environment("figure", stack_env)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.7"
|
|
@@ -131,8 +131,8 @@ def draw_heatmap(data, fig, img_name, axis: Axis):
|
|
|
131
131
|
axis.add_option("colormap", get_tikz_colorscale(DEFAULT_COLORSCALE))
|
|
132
132
|
|
|
133
133
|
tmp = np.where(figure_data == None, np.nan, figure_data)
|
|
134
|
-
axis.add_option("point meta max",
|
|
135
|
-
axis.add_option("point meta min",
|
|
134
|
+
axis.add_option("point meta max", np.nanmax(tmp))
|
|
135
|
+
axis.add_option("point meta min", np.nanmin(tmp))
|
|
136
136
|
axis.add_option("xmin", xmin)
|
|
137
137
|
axis.add_option("xmax", xmax)
|
|
138
138
|
axis.add_option("ymin", ymax)
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
from warnings import warn
|
|
2
|
+
|
|
3
|
+
# Source : https://github.com/plotly/plotly.py/blob/51eb5ea9fefda27bccfdb21e660b8d4035cef3b0/packages/python/plotly/plotly/graph_objs/box/_marker.py#L256-L344
|
|
4
|
+
AUTHORIZED_SYMBOLS = [0, '0', 'circle', 100, '100', 'circle-open', 200, '200',
|
|
5
|
+
'circle-dot', 300, '300', 'circle-open-dot', 1, '1',
|
|
6
|
+
'square', 101, '101', 'square-open', 201, '201',
|
|
7
|
+
'square-dot', 301, '301', 'square-open-dot', 2, '2',
|
|
8
|
+
'diamond', 102, '102', 'diamond-open', 202, '202',
|
|
9
|
+
'diamond-dot', 302, '302', 'diamond-open-dot', 3, '3',
|
|
10
|
+
'cross', 103, '103', 'cross-open', 203, '203',
|
|
11
|
+
'cross-dot', 303, '303', 'cross-open-dot', 4, '4', 'x',
|
|
12
|
+
104, '104', 'x-open', 204, '204', 'x-dot', 304, '304',
|
|
13
|
+
'x-open-dot', 5, '5', 'triangle-up', 105, '105',
|
|
14
|
+
'triangle-up-open', 205, '205', 'triangle-up-dot', 305,
|
|
15
|
+
'305', 'triangle-up-open-dot', 6, '6', 'triangle-down',
|
|
16
|
+
106, '106', 'triangle-down-open', 206, '206',
|
|
17
|
+
'triangle-down-dot', 306, '306', 'triangle-down-open-dot',
|
|
18
|
+
7, '7', 'triangle-left', 107, '107', 'triangle-left-open',
|
|
19
|
+
207, '207', 'triangle-left-dot', 307, '307',
|
|
20
|
+
'triangle-left-open-dot', 8, '8', 'triangle-right', 108,
|
|
21
|
+
'108', 'triangle-right-open', 208, '208',
|
|
22
|
+
'triangle-right-dot', 308, '308',
|
|
23
|
+
'triangle-right-open-dot', 9, '9', 'triangle-ne', 109,
|
|
24
|
+
'109', 'triangle-ne-open', 209, '209', 'triangle-ne-dot',
|
|
25
|
+
309, '309', 'triangle-ne-open-dot', 10, '10',
|
|
26
|
+
'triangle-se', 110, '110', 'triangle-se-open', 210, '210',
|
|
27
|
+
'triangle-se-dot', 310, '310', 'triangle-se-open-dot', 11,
|
|
28
|
+
'11', 'triangle-sw', 111, '111', 'triangle-sw-open', 211,
|
|
29
|
+
'211', 'triangle-sw-dot', 311, '311',
|
|
30
|
+
'triangle-sw-open-dot', 12, '12', 'triangle-nw', 112,
|
|
31
|
+
'112', 'triangle-nw-open', 212, '212', 'triangle-nw-dot',
|
|
32
|
+
312, '312', 'triangle-nw-open-dot', 13, '13', 'pentagon',
|
|
33
|
+
113, '113', 'pentagon-open', 213, '213', 'pentagon-dot',
|
|
34
|
+
313, '313', 'pentagon-open-dot', 14, '14', 'hexagon', 114,
|
|
35
|
+
'114', 'hexagon-open', 214, '214', 'hexagon-dot', 314,
|
|
36
|
+
'314', 'hexagon-open-dot', 15, '15', 'hexagon2', 115,
|
|
37
|
+
'115', 'hexagon2-open', 215, '215', 'hexagon2-dot', 315,
|
|
38
|
+
'315', 'hexagon2-open-dot', 16, '16', 'octagon', 116,
|
|
39
|
+
'116', 'octagon-open', 216, '216', 'octagon-dot', 316,
|
|
40
|
+
'316', 'octagon-open-dot', 17, '17', 'star', 117, '117',
|
|
41
|
+
'star-open', 217, '217', 'star-dot', 317, '317',
|
|
42
|
+
'star-open-dot', 18, '18', 'hexagram', 118, '118',
|
|
43
|
+
'hexagram-open', 218, '218', 'hexagram-dot', 318, '318',
|
|
44
|
+
'hexagram-open-dot', 19, '19', 'star-triangle-up', 119,
|
|
45
|
+
'119', 'star-triangle-up-open', 219, '219',
|
|
46
|
+
'star-triangle-up-dot', 319, '319',
|
|
47
|
+
'star-triangle-up-open-dot', 20, '20',
|
|
48
|
+
'star-triangle-down', 120, '120',
|
|
49
|
+
'star-triangle-down-open', 220, '220',
|
|
50
|
+
'star-triangle-down-dot', 320, '320',
|
|
51
|
+
'star-triangle-down-open-dot', 21, '21', 'star-square',
|
|
52
|
+
121, '121', 'star-square-open', 221, '221',
|
|
53
|
+
'star-square-dot', 321, '321', 'star-square-open-dot', 22,
|
|
54
|
+
'22', 'star-diamond', 122, '122', 'star-diamond-open',
|
|
55
|
+
222, '222', 'star-diamond-dot', 322, '322',
|
|
56
|
+
'star-diamond-open-dot', 23, '23', 'diamond-tall', 123,
|
|
57
|
+
'123', 'diamond-tall-open', 223, '223',
|
|
58
|
+
'diamond-tall-dot', 323, '323', 'diamond-tall-open-dot',
|
|
59
|
+
24, '24', 'diamond-wide', 124, '124', 'diamond-wide-open',
|
|
60
|
+
224, '224', 'diamond-wide-dot', 324, '324',
|
|
61
|
+
'diamond-wide-open-dot', 25, '25', 'hourglass', 125,
|
|
62
|
+
'125', 'hourglass-open', 26, '26', 'bowtie', 126, '126',
|
|
63
|
+
'bowtie-open', 27, '27', 'circle-cross', 127, '127',
|
|
64
|
+
'circle-cross-open', 28, '28', 'circle-x', 128, '128',
|
|
65
|
+
'circle-x-open', 29, '29', 'square-cross', 129, '129',
|
|
66
|
+
'square-cross-open', 30, '30', 'square-x', 130, '130',
|
|
67
|
+
'square-x-open', 31, '31', 'diamond-cross', 131, '131',
|
|
68
|
+
'diamond-cross-open', 32, '32', 'diamond-x', 132, '132',
|
|
69
|
+
'diamond-x-open', 33, '33', 'cross-thin', 133, '133',
|
|
70
|
+
'cross-thin-open', 34, '34', 'x-thin', 134, '134',
|
|
71
|
+
'x-thin-open', 35, '35', 'asterisk', 135, '135',
|
|
72
|
+
'asterisk-open', 36, '36', 'hash', 136, '136',
|
|
73
|
+
'hash-open', 236, '236', 'hash-dot', 336, '336',
|
|
74
|
+
'hash-open-dot', 37, '37', 'y-up', 137, '137',
|
|
75
|
+
'y-up-open', 38, '38', 'y-down', 138, '138',
|
|
76
|
+
'y-down-open', 39, '39', 'y-left', 139, '139',
|
|
77
|
+
'y-left-open', 40, '40', 'y-right', 140, '140',
|
|
78
|
+
'y-right-open', 41, '41', 'line-ew', 141, '141',
|
|
79
|
+
'line-ew-open', 42, '42', 'line-ns', 142, '142',
|
|
80
|
+
'line-ns-open', 43, '43', 'line-ne', 143, '143',
|
|
81
|
+
'line-ne-open', 44, '44', 'line-nw', 144, '144',
|
|
82
|
+
'line-nw-open', 45, '45', 'arrow-up', 145, '145',
|
|
83
|
+
'arrow-up-open', 46, '46', 'arrow-down', 146, '146',
|
|
84
|
+
'arrow-down-open', 47, '47', 'arrow-left', 147, '147',
|
|
85
|
+
'arrow-left-open', 48, '48', 'arrow-right', 148, '148',
|
|
86
|
+
'arrow-right-open', 49, '49', 'arrow-bar-up', 149, '149',
|
|
87
|
+
'arrow-bar-up-open', 50, '50', 'arrow-bar-down', 150,
|
|
88
|
+
'150', 'arrow-bar-down-open', 51, '51', 'arrow-bar-left',
|
|
89
|
+
151, '151', 'arrow-bar-left-open', 52, '52',
|
|
90
|
+
'arrow-bar-right', 152, '152', 'arrow-bar-right-open', 53,
|
|
91
|
+
'53', 'arrow', 153, '153', 'arrow-open', 54, '54',
|
|
92
|
+
'arrow-wide', 154, '154', 'arrow-wide-open']
|
|
93
|
+
|
|
94
|
+
marker_symbol_dict = {
|
|
95
|
+
"circle": ("*", None),
|
|
96
|
+
"circle-open": ("o", None),
|
|
97
|
+
"square": ("square*", None),
|
|
98
|
+
"square-open": ("square", None),
|
|
99
|
+
"diamond": ("diamond*", None),
|
|
100
|
+
"diamond-open": ("diamond", None),
|
|
101
|
+
|
|
102
|
+
"cross": ("+", None),
|
|
103
|
+
"cross-open": ("+", None),
|
|
104
|
+
"x": ("x", None),
|
|
105
|
+
"x-open": ("x", None),
|
|
106
|
+
|
|
107
|
+
"triangle-up": ("triangle*", None),
|
|
108
|
+
"triangle-up-open": ("triangle", None),
|
|
109
|
+
"triangle-down": ("triangle*", ("rotate", 180)),
|
|
110
|
+
"triangle-down-open": ("triangle", ("rotate", 180)),
|
|
111
|
+
"triangle-left": ("triangle*", ("rotate", 90)),
|
|
112
|
+
"triangle-left-open": ("triangle", ("rotate", 90)),
|
|
113
|
+
"triangle-right": ("triangle*", ("rotate", -90)),
|
|
114
|
+
"triangle-right-open": ("triangle", ("rotate", -90)),
|
|
115
|
+
"triangle-ne": ("triangle*", ("rotate", -45)),
|
|
116
|
+
"triangle-ne-open": ("triangle", ("rotate", -45)),
|
|
117
|
+
"triangle-se": ("triangle*", ("rotate", -135)),
|
|
118
|
+
"triangle-se-open": ("triangle", ("rotate", -135)),
|
|
119
|
+
"triangle-sw": ("triangle*", ("rotate", 135)),
|
|
120
|
+
"triangle-sw-open": ("triangle", ("rotate", 135)),
|
|
121
|
+
"triangle-nw": ("triangle*", ("rotate", 45)),
|
|
122
|
+
"triangle-nw-open": ("triangle", ("rotate", 45)),
|
|
123
|
+
|
|
124
|
+
"pentagon": ("pentagon*", None),
|
|
125
|
+
"pentagon-open": ("pentagon", None),
|
|
126
|
+
# "hexagon": ("hexagon*"",None), # not supported
|
|
127
|
+
# "hexagon-open": ("hexagon", None),
|
|
128
|
+
# "hexagon2": ("hexagon*", ("rotate", 90)),
|
|
129
|
+
# "hexagon2-open": ("hexagon", ("rotate", 90)),
|
|
130
|
+
# "octagon": ("octagon*", None),
|
|
131
|
+
# "octagon-open": ("octagon", None),
|
|
132
|
+
|
|
133
|
+
"star": ("star", None),
|
|
134
|
+
"star-open": ("star", None),
|
|
135
|
+
"hexagram": ("10-pointed star", None), # not supported
|
|
136
|
+
"hexagram-open": ("10-pointed star", None), # not supported
|
|
137
|
+
|
|
138
|
+
"star-triangle-up": ("triangle*", None), # not supported
|
|
139
|
+
"star-triangle-up-open": ("triangle", None), #
|
|
140
|
+
"star-triangle-down": ("triangle*", ("rotate", 180)), # not supported, but rotation of the previous
|
|
141
|
+
"star-triangle-down-open": ("triangle", ("rotate", 180)), #
|
|
142
|
+
"star-square": ("square*", None), # not supported
|
|
143
|
+
"star-square-open": ("square", None), # not supported
|
|
144
|
+
"star-diamond": ("diamond*", None), # not supported
|
|
145
|
+
"star-diamond-open": ("diamond", None), # not supported
|
|
146
|
+
|
|
147
|
+
"diamond-tall": ("diamond*", None),
|
|
148
|
+
"diamond-tall-open": ("diamond", None),
|
|
149
|
+
"diamond-wide": ("diamond*", ("rotate", 90)),
|
|
150
|
+
"diamond-wide-open": ("diamond", ("rotate", 90)),
|
|
151
|
+
|
|
152
|
+
# "hourglass": ("hourglass*", None); # not supported
|
|
153
|
+
# "hourglass-open": ("hourglass", None); #
|
|
154
|
+
# "bowtie": ("bowtie*", ("rotate", 90)); # not supported but rotation of the previous
|
|
155
|
+
# "bowtie-open": ("bowtie", ("rotate", 90)); #
|
|
156
|
+
|
|
157
|
+
"circle-cross": ("oplus*", None),
|
|
158
|
+
"circle-cross-open": ("oplus", None),
|
|
159
|
+
"circle-x": ("otimes*", None),
|
|
160
|
+
"circle-x-open": ("otimes", None),
|
|
161
|
+
"square-cross": ("square*", None), # not supported
|
|
162
|
+
"square-cross-open": ("square", None), #
|
|
163
|
+
"square-x": ("square*", None), #
|
|
164
|
+
"square-x-open": ("square", None), #
|
|
165
|
+
"diamond-cross": ("diamond*", None), #
|
|
166
|
+
"diamond-cross-open": ("diamond", None), #
|
|
167
|
+
"diamond-x": ("diamond*", None), #
|
|
168
|
+
"diamond-x-open": ("diamond", None), #
|
|
169
|
+
|
|
170
|
+
"cross-thin": ("+", None),
|
|
171
|
+
"x-thin": ("x", None),
|
|
172
|
+
"asterisk": ("asterisk", None),
|
|
173
|
+
# "hash": ("hash", None), # not supported
|
|
174
|
+
# "hash-open": ("hash", None),
|
|
175
|
+
|
|
176
|
+
"y-up": ("Mercedes star flipped", None),
|
|
177
|
+
"y-down": ("Mercedes star", None),
|
|
178
|
+
"y-left": ("Mercedes star", ("rotate", 90)),
|
|
179
|
+
"y-right": ("Mercedes star", ("rotate", -90)),
|
|
180
|
+
|
|
181
|
+
"line-ew": ("-", None),
|
|
182
|
+
"line-ns": ("|", None),
|
|
183
|
+
"line-ne": ("|", ("rotate", -45)),
|
|
184
|
+
"line-nw": ("|", ("rotate", 45)),
|
|
185
|
+
|
|
186
|
+
"arrow-up": ("triangle*", None), # not supported
|
|
187
|
+
"arrow-up-open": ("triangle", None), #
|
|
188
|
+
"arrow-down": ("triangle*", ("rotate", 180)), # not supported, but rotation of the previous
|
|
189
|
+
"arrow-down-open": ("triangle", ("rotate", 180)), #
|
|
190
|
+
"arrow-left": ("triangle*", ("rotate", 90)), #
|
|
191
|
+
"arrow-left-open": ("triangle", ("rotate", 90)), #
|
|
192
|
+
"arrow-right": ("triangle*", ("rotate", -90)), #
|
|
193
|
+
"arrow-right-open": ("triangle", ("rotate", -90)), #
|
|
194
|
+
"arrow-bar-up": ("triangle*", None), #
|
|
195
|
+
"arrow-bar-up-open": ("triangle", None), #
|
|
196
|
+
"arrow-bar-down": ("triangle*", ("rotate", 180)), #
|
|
197
|
+
"arrow-bar-down-open": ("triangle", ("rotate", 180)), #
|
|
198
|
+
"arrow-bar-left": ("triangle*", ("rotate", -90)), #
|
|
199
|
+
"arrow-bar-left-open": ("triangle", ("rotate", -90)), #
|
|
200
|
+
"arrow-bar-right": ("triangle*", ("rotate", 90)), #
|
|
201
|
+
"arrow-bar-right-open": ("triangle", ("rotate", 90)), #
|
|
202
|
+
"arrow": ("triangle*", ("xscale", 0.5)), # not supported
|
|
203
|
+
"arrow-open": ("triangle", ("xscale", 0.5)), #
|
|
204
|
+
"arrow-wide": ("triangle*", ("xscale", 1.5)), #
|
|
205
|
+
"arrow-wide-open": ("triangle", ("xscale", 1.5)), #
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
def marker_symbol_to_tex(symbol):
|
|
210
|
+
|
|
211
|
+
if symbol not in AUTHORIZED_SYMBOLS:
|
|
212
|
+
warn(f"Symbol '{symbol}' not supported, defaulting to '*'")
|
|
213
|
+
return "*", None
|
|
214
|
+
|
|
215
|
+
# Explanation : with plotly, there is a list of predefined symbols that can be given with a string or a corresponding integer.
|
|
216
|
+
# In the list AUTHORIZED_SYMBOLS (taken from plotly sources, see above), the symbols are given in the following order:
|
|
217
|
+
# the integer, then the interger as a string, then the symbol name. (e.g. 0, '0', 'circle')
|
|
218
|
+
idx = AUTHORIZED_SYMBOLS.index(symbol)
|
|
219
|
+
if idx % 3 == 0:
|
|
220
|
+
symbol_name = AUTHORIZED_SYMBOLS[idx + 2]
|
|
221
|
+
elif idx % 3 == 1:
|
|
222
|
+
symbol_name = AUTHORIZED_SYMBOLS[idx + 1]
|
|
223
|
+
else:
|
|
224
|
+
symbol_name = AUTHORIZED_SYMBOLS[idx]
|
|
225
|
+
|
|
226
|
+
if "-dot" in symbol_name:
|
|
227
|
+
warn("Dotted markers are not supported (yet), the symbol without dot will be used instead.")
|
|
228
|
+
return marker_symbol_dict.get(symbol_name.replace("-dot", ""), ("*", None))
|
|
@@ -54,7 +54,19 @@ def get_tikz_code(
|
|
|
54
54
|
warn("No data in figure.")
|
|
55
55
|
|
|
56
56
|
for trace in figure_data:
|
|
57
|
+
|
|
57
58
|
if trace.type == "scatter":
|
|
59
|
+
# Handle the case where x or y is empty
|
|
60
|
+
if trace.x is None and trace.y is None:
|
|
61
|
+
warn("Adding empty trace.")
|
|
62
|
+
data_str.append( "\\addplot coordinates {};\n" )
|
|
63
|
+
continue
|
|
64
|
+
else:
|
|
65
|
+
if trace.x is None:
|
|
66
|
+
trace.x = list(range(len(trace.y)))
|
|
67
|
+
if trace.y is None:
|
|
68
|
+
trace.y = list(range(len(trace.x)))
|
|
69
|
+
|
|
58
70
|
data_name_macro, y_name = data_container.addData(trace.x, trace.y, trace.name)
|
|
59
71
|
data_str.append( draw_scatter2d(data_name_macro, trace, y_name, axis, colors_set) )
|
|
60
72
|
if trace.name and trace['showlegend'] != False:
|
|
@@ -65,6 +77,11 @@ def get_tikz_code(
|
|
|
65
77
|
colors_set.add(convert_color(trace.fillcolor)[:3])
|
|
66
78
|
|
|
67
79
|
elif trace.type == "heatmap":
|
|
80
|
+
# Handle the case where x, y or z is empty
|
|
81
|
+
if trace.z is None:
|
|
82
|
+
warn("Adding empty trace.")
|
|
83
|
+
data_str.append( "\\addplot coordinates {};\n" )
|
|
84
|
+
continue
|
|
68
85
|
data_str.append( draw_heatmap(trace, fig, img_name, axis) )
|
|
69
86
|
|
|
70
87
|
else:
|
|
@@ -78,13 +95,16 @@ def get_tikz_code(
|
|
|
78
95
|
if include_disclamer:
|
|
79
96
|
code += tex_comment(f"This file was created with tikzplotly version {__version__}.")
|
|
80
97
|
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
if len(data_container.data) > 0:
|
|
99
|
+
code += data_container.exportData()
|
|
100
|
+
code += "\n"
|
|
83
101
|
|
|
84
102
|
code += tex_begin_environment("tikzpicture", stack_env, options=tikz_options)
|
|
85
103
|
|
|
86
104
|
code += "\n"
|
|
87
|
-
|
|
105
|
+
color_list = list(colors_set)
|
|
106
|
+
color_list.sort()
|
|
107
|
+
for color in color_list:
|
|
88
108
|
code += tex_add_color(color[0], color[1], color[2])
|
|
89
109
|
code += "\n"
|
|
90
110
|
|
|
@@ -107,7 +127,7 @@ def get_tikz_code(
|
|
|
107
127
|
return code
|
|
108
128
|
|
|
109
129
|
|
|
110
|
-
def save(filepath
|
|
130
|
+
def save(filepath, *args, **kwargs):
|
|
111
131
|
"""Save a figure to a file or a stream.
|
|
112
132
|
|
|
113
133
|
Parameters
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tikzplotly
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Convert plotly figures to LaTeX / tikz figures
|
|
5
5
|
Author-email: Thomas Saigre <tikzplotly@outlook.fr>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -30,7 +30,6 @@ Keywords: plotly,latex,tikz,figure,conversion,graphics
|
|
|
30
30
|
Classifier: Development Status :: 5 - Production/Stable
|
|
31
31
|
Classifier: Programming Language :: Python
|
|
32
32
|
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
34
33
|
Classifier: Programming Language :: Python :: 3.8
|
|
35
34
|
Classifier: Programming Language :: Python :: 3.9
|
|
36
35
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -52,6 +51,9 @@ Requires-Dist: pandas; extra == "dev"
|
|
|
52
51
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
53
52
|
|
|
54
53
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
54
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
55
|
+

|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
# Tikzplotly
|
|
57
59
|
|
|
@@ -22,4 +22,8 @@ src/tikzplotly.egg-info/PKG-INFO
|
|
|
22
22
|
src/tikzplotly.egg-info/SOURCES.txt
|
|
23
23
|
src/tikzplotly.egg-info/dependency_links.txt
|
|
24
24
|
src/tikzplotly.egg-info/requires.txt
|
|
25
|
-
src/tikzplotly.egg-info/top_level.txt
|
|
25
|
+
src/tikzplotly.egg-info/top_level.txt
|
|
26
|
+
tests/test_heatmap.py
|
|
27
|
+
tests/test_markers.py
|
|
28
|
+
tests/test_scatter.py
|
|
29
|
+
tests/test_tikzplotly.py
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from .helpers import assert_equality
|
|
6
|
+
import pathlib
|
|
7
|
+
import datetime
|
|
8
|
+
|
|
9
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
10
|
+
test_name = "test_heatmap"
|
|
11
|
+
pathlib.Path("/tmp/tikzplotly").mkdir(parents=True, exist_ok=True)
|
|
12
|
+
|
|
13
|
+
def plot_1():
|
|
14
|
+
fig = px.imshow([[1, 20, 30],
|
|
15
|
+
[20, 1, 60],
|
|
16
|
+
[30, 60, 1]])
|
|
17
|
+
return fig
|
|
18
|
+
|
|
19
|
+
def plot_2():
|
|
20
|
+
df = px.data.medals_wide(indexed=True)
|
|
21
|
+
fig = px.imshow(df)
|
|
22
|
+
return fig
|
|
23
|
+
|
|
24
|
+
def plot_3():
|
|
25
|
+
fig = go.Figure(data=go.Heatmap(
|
|
26
|
+
z=[[1, None, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]],
|
|
27
|
+
x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
|
28
|
+
y=['Morning', 'Afternoon', 'Evening'],
|
|
29
|
+
hoverongaps = False))
|
|
30
|
+
return fig
|
|
31
|
+
|
|
32
|
+
def plot_4():
|
|
33
|
+
import plotly.graph_objects as go
|
|
34
|
+
|
|
35
|
+
programmers = ['Alex','Nicole','Sara','Etienne','Chelsea','Jody','Marianne']
|
|
36
|
+
|
|
37
|
+
base = datetime.datetime(2021, 7, 20, 19, 30, 0)
|
|
38
|
+
dates = base - np.arange(180) * datetime.timedelta(days=1)
|
|
39
|
+
np.random.seed(43)
|
|
40
|
+
z = np.random.poisson(size=(len(programmers), len(dates)))
|
|
41
|
+
|
|
42
|
+
fig = go.Figure(data=go.Heatmap(
|
|
43
|
+
z=z,
|
|
44
|
+
x=dates,
|
|
45
|
+
y=programmers,
|
|
46
|
+
colorscale='Viridis'))
|
|
47
|
+
|
|
48
|
+
fig.update_layout(
|
|
49
|
+
title='GitHub commits per day',
|
|
50
|
+
xaxis_nticks=36)
|
|
51
|
+
|
|
52
|
+
return fig
|
|
53
|
+
|
|
54
|
+
def plot_5():
|
|
55
|
+
fig = px.imshow([[1, 20, 30],
|
|
56
|
+
[20, 1, 60],
|
|
57
|
+
[30, 60, 1]])
|
|
58
|
+
fig.data[0].z = None
|
|
59
|
+
return fig
|
|
60
|
+
|
|
61
|
+
def test_1():
|
|
62
|
+
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"), img_name="/tmp/tikzplotly/fig1.png")
|
|
63
|
+
|
|
64
|
+
def test_2():
|
|
65
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"), img_name="/tmp/tikzplotly/fig2.png")
|
|
66
|
+
|
|
67
|
+
def test_3():
|
|
68
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"), img_name="/tmp/tikzplotly/fig3.png")
|
|
69
|
+
|
|
70
|
+
def test_4():
|
|
71
|
+
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png")
|
|
72
|
+
|
|
73
|
+
def test_5():
|
|
74
|
+
assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex"))
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import pytest
|
|
4
|
+
import numpy as np
|
|
5
|
+
import os
|
|
6
|
+
from .helpers import assert_equality
|
|
7
|
+
import pathlib
|
|
8
|
+
|
|
9
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
10
|
+
test_name = "test_markers"
|
|
11
|
+
|
|
12
|
+
def plot_1(symbol):
|
|
13
|
+
|
|
14
|
+
df = px.data.iris()
|
|
15
|
+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
|
|
16
|
+
|
|
17
|
+
fig.update_traces(marker=dict(size=12,
|
|
18
|
+
symbol = symbol,
|
|
19
|
+
line=dict(width=2,
|
|
20
|
+
color='DarkSlateGrey')),
|
|
21
|
+
selector=dict(mode='markers'))
|
|
22
|
+
return fig
|
|
23
|
+
|
|
24
|
+
def plot_2():
|
|
25
|
+
np.random.seed(1)
|
|
26
|
+
x = np.random.uniform(low=3, high=6, size=(500,))
|
|
27
|
+
y = np.random.uniform(low=3, high=6, size=(500,))
|
|
28
|
+
|
|
29
|
+
# Build figure
|
|
30
|
+
fig = go.Figure()
|
|
31
|
+
|
|
32
|
+
# Add scatter trace with medium sized markers
|
|
33
|
+
fig.add_trace(
|
|
34
|
+
go.Scatter(
|
|
35
|
+
mode='markers',
|
|
36
|
+
x=x,
|
|
37
|
+
y=y,
|
|
38
|
+
marker=dict(
|
|
39
|
+
color='LightSkyBlue',
|
|
40
|
+
size=20,
|
|
41
|
+
opacity=0.5,
|
|
42
|
+
line=dict(
|
|
43
|
+
color='MediumPurple',
|
|
44
|
+
width=2
|
|
45
|
+
)
|
|
46
|
+
),
|
|
47
|
+
showlegend=False
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Add trace with large markers
|
|
53
|
+
fig.add_trace(
|
|
54
|
+
go.Scatter(
|
|
55
|
+
mode='markers',
|
|
56
|
+
x=[2, 2],
|
|
57
|
+
y=[4.25, 4.75],
|
|
58
|
+
marker=dict(
|
|
59
|
+
color='LightSkyBlue',
|
|
60
|
+
size=80,
|
|
61
|
+
opacity=0.5,
|
|
62
|
+
line=dict(
|
|
63
|
+
color='MediumPurple',
|
|
64
|
+
width=8
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
showlegend=False
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return fig
|
|
72
|
+
|
|
73
|
+
def plot_3():
|
|
74
|
+
df = px.data.iris()
|
|
75
|
+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
|
|
76
|
+
|
|
77
|
+
fig.update_traces(
|
|
78
|
+
marker=dict(size=8, symbol="diamond", line=dict(width=2, color="DarkSlateGrey")),
|
|
79
|
+
selector=dict(mode="markers"),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return fig
|
|
83
|
+
|
|
84
|
+
@pytest.mark.parametrize("symbol", ["circle", 0, "0"])
|
|
85
|
+
def test_1(symbol):
|
|
86
|
+
assert_equality(plot_1(symbol), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))
|
|
87
|
+
|
|
88
|
+
def test_2():
|
|
89
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
|
|
90
|
+
|
|
91
|
+
def test_3():
|
|
92
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"))
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from .helpers import assert_equality
|
|
6
|
+
import pathlib
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
10
|
+
test_name = "test_scatter"
|
|
11
|
+
|
|
12
|
+
def plot_1():
|
|
13
|
+
df = px.data.gapminder().query("continent == 'Oceania'")
|
|
14
|
+
fig = px.line(df, x='year', y='lifeExp', color='country', markers=True)
|
|
15
|
+
return fig
|
|
16
|
+
|
|
17
|
+
def plot_2():
|
|
18
|
+
df = px.data.gapminder().query("country in ['Canada', 'Botswana']")
|
|
19
|
+
fig = px.line(df, x="lifeExp", y="gdpPercap", color="country", text="year")
|
|
20
|
+
fig.update_traces(textposition="bottom right")
|
|
21
|
+
|
|
22
|
+
# fig.show()
|
|
23
|
+
return fig
|
|
24
|
+
|
|
25
|
+
def plot_3():
|
|
26
|
+
x = np.arange(10)
|
|
27
|
+
fig = go.Figure(data=go.Scatter(x=x, y=x**2))
|
|
28
|
+
return fig
|
|
29
|
+
|
|
30
|
+
def plot_4():
|
|
31
|
+
labels = ['Television', 'Newspaper', 'Internet', 'Radio']
|
|
32
|
+
colors = ['rgb(67,67,67)', 'rgb(115,115,115)', 'rgb(49,130,189)', 'rgb(189,189,189)']
|
|
33
|
+
|
|
34
|
+
mode_size = [4, 4, 6, 4]
|
|
35
|
+
line_size = [2, 2, 4, 2]
|
|
36
|
+
|
|
37
|
+
x_data = np.vstack((np.arange(2001, 2013),)*4)
|
|
38
|
+
|
|
39
|
+
y_data = np.array([
|
|
40
|
+
[74, 82, 80, 74, 73, 72, 74, 70, 70, 66, 66, 69],
|
|
41
|
+
[45, 42, 50, 46, 36, 36, 34, 35, 32, 31, 31, 28],
|
|
42
|
+
[13, 14, 20, 24, 20, 24, 24, 40, 35, 41, 43, 50],
|
|
43
|
+
[18, 21, 18, 21, 16, 14, 13, 18, 17, 16, 19, 23],
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
fig = go.Figure()
|
|
47
|
+
|
|
48
|
+
for i in range(0, 4):
|
|
49
|
+
fig.add_trace(go.Scatter(x=x_data[i], y=y_data[i], mode='lines',
|
|
50
|
+
name=labels[i],
|
|
51
|
+
line=dict(color=colors[i], width=line_size[i]),
|
|
52
|
+
connectgaps=True,
|
|
53
|
+
))
|
|
54
|
+
|
|
55
|
+
# endpoints
|
|
56
|
+
fig.add_trace(go.Scatter(
|
|
57
|
+
x=[x_data[i][0], x_data[i][-1]],
|
|
58
|
+
y=[y_data[i][0], y_data[i][-1]],
|
|
59
|
+
mode='markers',
|
|
60
|
+
marker=dict(color=colors[i], size=mode_size[i])
|
|
61
|
+
))
|
|
62
|
+
|
|
63
|
+
fig.update_layout(
|
|
64
|
+
xaxis=dict(
|
|
65
|
+
showline=True,
|
|
66
|
+
showgrid=False,
|
|
67
|
+
showticklabels=True,
|
|
68
|
+
linecolor='rgb(204, 204, 204)',
|
|
69
|
+
linewidth=2,
|
|
70
|
+
ticks='outside',
|
|
71
|
+
tickfont=dict(
|
|
72
|
+
family='Arial',
|
|
73
|
+
size=12,
|
|
74
|
+
color='rgb(82, 82, 82)',
|
|
75
|
+
),
|
|
76
|
+
),
|
|
77
|
+
yaxis=dict(
|
|
78
|
+
showgrid=False,
|
|
79
|
+
zeroline=False,
|
|
80
|
+
showline=False,
|
|
81
|
+
showticklabels=False,
|
|
82
|
+
),
|
|
83
|
+
autosize=False,
|
|
84
|
+
margin=dict(
|
|
85
|
+
autoexpand=False,
|
|
86
|
+
l=100,
|
|
87
|
+
r=20,
|
|
88
|
+
t=110,
|
|
89
|
+
),
|
|
90
|
+
showlegend=False,
|
|
91
|
+
plot_bgcolor='white'
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
annotations = []
|
|
95
|
+
|
|
96
|
+
# Adding labels
|
|
97
|
+
for y_trace, label, color in zip(y_data, labels, colors):
|
|
98
|
+
# labeling the left_side of the plot
|
|
99
|
+
annotations.append(dict(xref='paper', x=0.05, y=y_trace[0],
|
|
100
|
+
xanchor='right', yanchor='middle',
|
|
101
|
+
text=label + ' {}%'.format(y_trace[0]),
|
|
102
|
+
font=dict(family='Arial',
|
|
103
|
+
size=16),
|
|
104
|
+
showarrow=False))
|
|
105
|
+
# labeling the right_side of the plot
|
|
106
|
+
annotations.append(dict(xref='paper', x=0.95, y=y_trace[11],
|
|
107
|
+
xanchor='left', yanchor='middle',
|
|
108
|
+
text='{}%'.format(y_trace[11]),
|
|
109
|
+
font=dict(family='Arial',
|
|
110
|
+
size=16),
|
|
111
|
+
showarrow=False))
|
|
112
|
+
# Title
|
|
113
|
+
annotations.append(dict(xref='paper', yref='paper', x=0.0, y=1.05,
|
|
114
|
+
xanchor='left', yanchor='bottom',
|
|
115
|
+
text='Main Source for News',
|
|
116
|
+
font=dict(family='Arial',
|
|
117
|
+
size=30,
|
|
118
|
+
color='rgb(37,37,37)'),
|
|
119
|
+
showarrow=False))
|
|
120
|
+
# Source
|
|
121
|
+
annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.1,
|
|
122
|
+
xanchor='center', yanchor='top',
|
|
123
|
+
text='Source: PewResearch Center & ' +
|
|
124
|
+
'Storytelling with data',
|
|
125
|
+
font=dict(family='Arial',
|
|
126
|
+
size=12,
|
|
127
|
+
color='rgb(150,150,150)'),
|
|
128
|
+
showarrow=False))
|
|
129
|
+
|
|
130
|
+
fig.update_layout(annotations=annotations)
|
|
131
|
+
|
|
132
|
+
# fig.show()
|
|
133
|
+
return fig
|
|
134
|
+
|
|
135
|
+
def plot_5():
|
|
136
|
+
df = px.data.stocks()
|
|
137
|
+
fig = px.line(df, x='date', y="GOOG")
|
|
138
|
+
return fig
|
|
139
|
+
|
|
140
|
+
def plot_6(x=True, y=True):
|
|
141
|
+
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
|
|
142
|
+
if x: fig.data[0].x = None
|
|
143
|
+
if y: fig.data[0].y = None
|
|
144
|
+
return fig
|
|
145
|
+
|
|
146
|
+
def test_1():
|
|
147
|
+
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))
|
|
148
|
+
|
|
149
|
+
def test_2():
|
|
150
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
|
|
151
|
+
|
|
152
|
+
def test_3():
|
|
153
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"))
|
|
154
|
+
|
|
155
|
+
def test_4():
|
|
156
|
+
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"))
|
|
157
|
+
|
|
158
|
+
def test_5():
|
|
159
|
+
assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex"))
|
|
160
|
+
|
|
161
|
+
@pytest.mark.parametrize("x, y", [(True, True), (True, False), (False, True)])
|
|
162
|
+
def test_6(x, y):
|
|
163
|
+
assert_equality(plot_6(x, y), os.path.join(this_dir, test_name, test_name + f"_6_{x}_{y}_reference.tex"))
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.4"
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
from warnings import warn
|
|
2
|
-
|
|
3
|
-
marker_symbol_dict = {
|
|
4
|
-
"circle": ("*", None),
|
|
5
|
-
"circle-open": ("o", None),
|
|
6
|
-
"square": ("square*", None),
|
|
7
|
-
"square-open": ("square", None),
|
|
8
|
-
"diamond": ("diamond*", None),
|
|
9
|
-
"diamond-open": ("diamond", None),
|
|
10
|
-
|
|
11
|
-
"cross": ("+", None),
|
|
12
|
-
"cross-open": ("+", None),
|
|
13
|
-
"x": ("x", None),
|
|
14
|
-
"x-open": ("x", None),
|
|
15
|
-
|
|
16
|
-
"triangle-up": ("triangle*", None),
|
|
17
|
-
"triangle-up-open": ("triangle", None),
|
|
18
|
-
"triangle-down": ("triangle*", ("rotate", 180)),
|
|
19
|
-
"triangle-down-open": ("triangle", ("rotate", 180)),
|
|
20
|
-
"triangle-left": ("triangle*", ("rotate", 90)),
|
|
21
|
-
"triangle-left-open": ("triangle", ("rotate", 90)),
|
|
22
|
-
"triangle-right": ("triangle*", ("rotate", -90)),
|
|
23
|
-
"triangle-right-open": ("triangle", ("rotate", -90)),
|
|
24
|
-
"triangle-ne": ("triangle*", ("rotate", -45)),
|
|
25
|
-
"triangle-ne-open": ("triangle", ("rotate", -45)),
|
|
26
|
-
"triangle-se": ("triangle*", ("rotate", -135)),
|
|
27
|
-
"triangle-se-open": ("triangle", ("rotate", -135)),
|
|
28
|
-
"triangle-sw": ("triangle*", ("rotate", 135)),
|
|
29
|
-
"triangle-sw-open": ("triangle", ("rotate", 135)),
|
|
30
|
-
"triangle-nw": ("triangle*", ("rotate", 45)),
|
|
31
|
-
"triangle-nw-open": ("triangle", ("rotate", 45)),
|
|
32
|
-
|
|
33
|
-
"pentagon": ("pentagon*", None),
|
|
34
|
-
"pentagon-open": ("pentagon", None),
|
|
35
|
-
# "hexagon": ("hexagon*"",None), # not supported
|
|
36
|
-
# "hexagon-open": ("hexagon", None),
|
|
37
|
-
# "hexagon2": ("hexagon*", ("rotate", 90)),
|
|
38
|
-
# "hexagon2-open": ("hexagon", ("rotate", 90)),
|
|
39
|
-
# "octagon": ("octagon*", None),
|
|
40
|
-
# "octagon-open": ("octagon", None),
|
|
41
|
-
|
|
42
|
-
"star": ("star", None),
|
|
43
|
-
"star-open": ("star", None),
|
|
44
|
-
"hexagram": ("10-pointed star", None), # not supported
|
|
45
|
-
"hexagram-open": ("10-pointed star", None), # not supported
|
|
46
|
-
|
|
47
|
-
"star-triangle-up": ("triangle*", None), # not supported
|
|
48
|
-
"star-triangle-up-open": ("triangle", None), #
|
|
49
|
-
"star-triangle-down": ("triangle*", ("rotate", 180)), # not supported, but rotation of the previous
|
|
50
|
-
"star-triangle-down-open": ("triangle", ("rotate", 180)), #
|
|
51
|
-
"star-square": ("square*", None), # not supported
|
|
52
|
-
"star-square-open": ("square", None), # not supported
|
|
53
|
-
"star-diamond": ("diamond*", None), # not supported
|
|
54
|
-
"star-diamond-open": ("diamond", None), # not supported
|
|
55
|
-
|
|
56
|
-
"diamond-tall": ("diamond*", None),
|
|
57
|
-
"diamond-tall-open": ("diamond", None),
|
|
58
|
-
"diamond-wide": ("diamond*", ("rotate", 90)),
|
|
59
|
-
"diamond-wide-open": ("diamond", ("rotate", 90)),
|
|
60
|
-
|
|
61
|
-
# "hourglass": ("hourglass*", None); # not supported
|
|
62
|
-
# "hourglass-open": ("hourglass", None); #
|
|
63
|
-
# "bowtie": ("bowtie*", ("rotate", 90)); # not supported but rotation of the previous
|
|
64
|
-
# "bowtie-open": ("bowtie", ("rotate", 90)); #
|
|
65
|
-
|
|
66
|
-
"circle-cross": ("oplus*", None),
|
|
67
|
-
"circle-cross-open": ("oplus", None),
|
|
68
|
-
"circle-x": ("otimes*", None),
|
|
69
|
-
"circle-x-open": ("otimes", None),
|
|
70
|
-
"square-cross": ("square*", None), # not supported
|
|
71
|
-
"square-cross-open": ("square", None), #
|
|
72
|
-
"square-x": ("square*", None), #
|
|
73
|
-
"square-x-open": ("square", None), #
|
|
74
|
-
"diamond-cross": ("diamond*", None), #
|
|
75
|
-
"diamond-cross-open": ("diamond", None), #
|
|
76
|
-
"diamond-x": ("diamond*", None), #
|
|
77
|
-
"diamond-x-open": ("diamond", None), #
|
|
78
|
-
|
|
79
|
-
"cross-thin": ("+", None),
|
|
80
|
-
"x-thin": ("x", None),
|
|
81
|
-
"asterisk": ("asterisk", None),
|
|
82
|
-
# "hash": ("hash", None), # not supported
|
|
83
|
-
# "hash-open": ("hash", None),
|
|
84
|
-
|
|
85
|
-
"y-up": ("Mercedes star flipped", None),
|
|
86
|
-
"y-down": ("Mercedes star", None),
|
|
87
|
-
"y-left": ("Mercedes star", ("rotate", 90)),
|
|
88
|
-
"y-right": ("Mercedes star", ("rotate", -90)),
|
|
89
|
-
|
|
90
|
-
"line-ew": ("-", None),
|
|
91
|
-
"line-ns": ("|", None),
|
|
92
|
-
"line-ne": ("|", ("rotate", -45)),
|
|
93
|
-
"line-nw": ("|", ("rotate", 45)),
|
|
94
|
-
|
|
95
|
-
"arrow-up": ("triangle*", None), # not supported
|
|
96
|
-
"arrow-up-open": ("triangle", None), #
|
|
97
|
-
"arrow-down": ("triangle*", ("rotate", 180)), # not supported, but rotation of the previous
|
|
98
|
-
"arrow-down-open": ("triangle", ("rotate", 180)), #
|
|
99
|
-
"arrow-left": ("triangle*", ("rotate", 90)), #
|
|
100
|
-
"arrow-left-open": ("triangle", ("rotate", 90)), #
|
|
101
|
-
"arrow-right": ("triangle*", ("rotate", -90)), #
|
|
102
|
-
"arrow-right-open": ("triangle", ("rotate", -90)), #
|
|
103
|
-
"arrow-bar-up": ("triangle*", None), #
|
|
104
|
-
"arrow-bar-up-open": ("triangle", None), #
|
|
105
|
-
"arrow-bar-down": ("triangle*", ("rotate", 180)), #
|
|
106
|
-
"arrow-bar-down-open": ("triangle", ("rotate", 180)), #
|
|
107
|
-
"arrow-bar-left": ("triangle*", ("rotate", -90)), #
|
|
108
|
-
"arrow-bar-left-open": ("triangle", ("rotate", -90)), #
|
|
109
|
-
"arrow-bar-right": ("triangle*", ("rotate", 90)), #
|
|
110
|
-
"arrow-bar-right-open": ("triangle", ("rotate", 90)), #
|
|
111
|
-
"arrow": ("triangle*", ("xscale", 0.5)), # not supported
|
|
112
|
-
"arrow-open": ("triangle", ("xscale", 0.5)), #
|
|
113
|
-
"arrow-wide": ("triangle*", ("xscale", 1.5)), #
|
|
114
|
-
"arrow-wide-open": ("triangle", ("xscale", 1.5)), #
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
def marker_symbol_to_tex(symbol):
|
|
119
|
-
if "-dot" in symbol:
|
|
120
|
-
warn("Dotted markers are not supported (yet), the symbol without dot will be used instead.")
|
|
121
|
-
return marker_symbol_dict.get(symbol.replace("-dot", ""), ("*", None))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|