tikzplotly 0.1.6__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.6 → tikzplotly-0.1.7}/PKG-INFO +1 -1
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/pyproject.toml +1 -1
- tikzplotly-0.1.7/src/tikzplotly/__about__.py +1 -0
- tikzplotly-0.1.7/src/tikzplotly/_marker.py +228 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_save.py +17 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/PKG-INFO +1 -1
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/SOURCES.txt +2 -1
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/tests/test_heatmap.py +10 -1
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/tests/test_markers.py +6 -3
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/tests/test_scatter.py +12 -1
- tikzplotly-0.1.7/tests/test_tikzplotly.py +6 -0
- tikzplotly-0.1.6/src/tikzplotly/__about__.py +0 -1
- tikzplotly-0.1.6/src/tikzplotly/_marker.py +0 -121
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/LICENSE +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/README.md +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/setup.cfg +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tests/test_heatmaps.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tests/test_line_charts.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tests/test_markers.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/__init__.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_annotations.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_axis.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_color.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_dash.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_data.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_dataContainer.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_heatmap.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_scatter.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_tex.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly/_utils.py +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/dependency_links.txt +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/requires.txt +0 -0
- {tikzplotly-0.1.6 → tikzplotly-0.1.7}/src/tikzplotly.egg-info/top_level.txt +0 -0
|
@@ -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"}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.7"
|
|
@@ -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:
|
|
@@ -51,6 +51,12 @@ def plot_4():
|
|
|
51
51
|
|
|
52
52
|
return fig
|
|
53
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
|
|
54
60
|
|
|
55
61
|
def test_1():
|
|
56
62
|
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"), img_name="/tmp/tikzplotly/fig1.png")
|
|
@@ -62,4 +68,7 @@ def test_3():
|
|
|
62
68
|
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"), img_name="/tmp/tikzplotly/fig3.png")
|
|
63
69
|
|
|
64
70
|
def test_4():
|
|
65
|
-
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png")
|
|
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"))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import plotly.express as px
|
|
2
2
|
import plotly.graph_objects as go
|
|
3
|
+
import pytest
|
|
3
4
|
import numpy as np
|
|
4
5
|
import os
|
|
5
6
|
from .helpers import assert_equality
|
|
@@ -8,12 +9,13 @@ import pathlib
|
|
|
8
9
|
this_dir = pathlib.Path(__file__).resolve().parent
|
|
9
10
|
test_name = "test_markers"
|
|
10
11
|
|
|
11
|
-
def plot_1():
|
|
12
|
+
def plot_1(symbol):
|
|
12
13
|
|
|
13
14
|
df = px.data.iris()
|
|
14
15
|
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
|
|
15
16
|
|
|
16
17
|
fig.update_traces(marker=dict(size=12,
|
|
18
|
+
symbol = symbol,
|
|
17
19
|
line=dict(width=2,
|
|
18
20
|
color='DarkSlateGrey')),
|
|
19
21
|
selector=dict(mode='markers'))
|
|
@@ -79,8 +81,9 @@ def plot_3():
|
|
|
79
81
|
|
|
80
82
|
return fig
|
|
81
83
|
|
|
82
|
-
|
|
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"))
|
|
84
87
|
|
|
85
88
|
def test_2():
|
|
86
89
|
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
|
|
@@ -4,6 +4,7 @@ import numpy as np
|
|
|
4
4
|
import os
|
|
5
5
|
from .helpers import assert_equality
|
|
6
6
|
import pathlib
|
|
7
|
+
import pytest
|
|
7
8
|
|
|
8
9
|
this_dir = pathlib.Path(__file__).resolve().parent
|
|
9
10
|
test_name = "test_scatter"
|
|
@@ -136,6 +137,12 @@ def plot_5():
|
|
|
136
137
|
fig = px.line(df, x='date', y="GOOG")
|
|
137
138
|
return fig
|
|
138
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
|
+
|
|
139
146
|
def test_1():
|
|
140
147
|
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))
|
|
141
148
|
|
|
@@ -149,4 +156,8 @@ def test_4():
|
|
|
149
156
|
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"))
|
|
150
157
|
|
|
151
158
|
def test_5():
|
|
152
|
-
assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex"))
|
|
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.6"
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|