tikzplotly 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl
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/__about__.py +1 -1
- tikzplotly/_color.py +10 -9
- tikzplotly/{_dataContainer.py → _data_container.py} +1 -1
- tikzplotly/_heatmap.py +3 -2
- tikzplotly/_histogram.py +27 -27
- tikzplotly/_polar.py +1 -1
- tikzplotly/_save.py +4 -4
- tikzplotly/_scatter.py +6 -36
- tikzplotly/_scatter3d.py +6 -35
- tikzplotly/_trace_utils.py +70 -0
- tikzplotly/_utils.py +2 -10
- {tikzplotly-0.2.1.dist-info → tikzplotly-0.2.2.dist-info}/METADATA +2 -1
- {tikzplotly-0.2.1.dist-info → tikzplotly-0.2.2.dist-info}/RECORD +16 -15
- {tikzplotly-0.2.1.dist-info → tikzplotly-0.2.2.dist-info}/WHEEL +1 -1
- {tikzplotly-0.2.1.dist-info → tikzplotly-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {tikzplotly-0.2.1.dist-info → tikzplotly-0.2.2.dist-info}/top_level.txt +0 -0
tikzplotly/__about__.py
CHANGED
tikzplotly/_color.py
CHANGED
|
@@ -30,7 +30,7 @@ def convert_color(color):
|
|
|
30
30
|
string from plotly color palette, can be one of the following:
|
|
31
31
|
- hex string : "#______"
|
|
32
32
|
- rgb string : "rgb(__, __, __)" with values between 0 and 255
|
|
33
|
-
- rgba string : "rgba(__, __, __, __)" with values between 0 and 255 and an opacity value between 0 and 1
|
|
33
|
+
- rgba string : "rgba(__, __, __[, __])" with values between 0 and 255 and an opacity value between 0 and 1 (optional)
|
|
34
34
|
- color name : "red", "green", "blue", "yellow", "orange", "purple", "brown", "black", "gray", "white" or any other color name from
|
|
35
35
|
https://github.com/plotly/plotly.py/blob/main/templategen/utils/colors.py
|
|
36
36
|
|
|
@@ -45,20 +45,21 @@ def convert_color(color):
|
|
|
45
45
|
if color is None:
|
|
46
46
|
return None, None, None, 1
|
|
47
47
|
if isinstance(color, numpy.ndarray):
|
|
48
|
-
warn("Color from data is not supported yet. Returning
|
|
49
|
-
return
|
|
48
|
+
warn("Color from data is not supported yet. Returning no color.")
|
|
49
|
+
return None, None, None, 1
|
|
50
50
|
if not isinstance(color, str):
|
|
51
|
-
warn(f"Color {color} type '{color.__class__.__name__}' is not supported yet. Returning
|
|
52
|
-
return
|
|
51
|
+
warn(f"Color {color} type '{color.__class__.__name__}' is not supported yet. Returning no color.")
|
|
52
|
+
return None, None, None, 1
|
|
53
53
|
|
|
54
54
|
if color.startswith("#"):
|
|
55
55
|
return color[1:], "HTML", color[1:], 1
|
|
56
56
|
|
|
57
57
|
if color.startswith("rgba"):
|
|
58
|
-
sp = color.split("(")[1].split(",")
|
|
59
|
-
rgb_color = sp
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
sp = color.split("(")[1].replace(')', '').split(",")
|
|
59
|
+
rgb_color = [s.strip() for s in sp]
|
|
60
|
+
r, g, b = int(rgb_color[0]), int(rgb_color[1]), int(rgb_color[2])
|
|
61
|
+
opacity = float(rgb_color[3]) if len(rgb_color) == 4 else 1.0
|
|
62
|
+
return hashlib.sha1(f"{r}, {g}, {b}".encode('UTF-8')).hexdigest()[:10], "RGB", rgb_str(r, g, b), opacity
|
|
62
63
|
|
|
63
64
|
if color.startswith("rgb"):
|
|
64
65
|
color = color[4:-1].replace("[", "{").replace("]", "}")
|
|
@@ -186,7 +186,7 @@ class DataContainer:
|
|
|
186
186
|
return data.name, data.z_name
|
|
187
187
|
data_obj = Data3D(x, y, z, name)
|
|
188
188
|
self.data.append(data_obj)
|
|
189
|
-
return data_obj.name
|
|
189
|
+
return data_obj.name
|
|
190
190
|
|
|
191
191
|
def export_data(self):
|
|
192
192
|
"""Generate LaTeX code to export the data from DataContainer.
|
tikzplotly/_heatmap.py
CHANGED
|
@@ -102,9 +102,10 @@ def draw_heatmap(data, fig, img_name, axis: Axis):
|
|
|
102
102
|
|
|
103
103
|
img_bytes = fig_copy.to_image(format="png") # The image created by plotly keeps places around the heatmap
|
|
104
104
|
cropped_image = crop_image(Image.open(io.BytesIO(img_bytes))) # so we crop all the white around the figure
|
|
105
|
-
resized_image = resize_image(cropped_image, *figure_data.shape)
|
|
105
|
+
resized_image = resize_image(cropped_image, *figure_data.shape) # and we resize it so each square is a 1px x 1px square
|
|
106
106
|
|
|
107
|
-
os.
|
|
107
|
+
dirname = os.path.dirname(img_name) or '.' # Ensure that dirname is not empty
|
|
108
|
+
os.makedirs(dirname, exist_ok=True) # Make sure the directory exists
|
|
108
109
|
resized_image.save(img_name)
|
|
109
110
|
|
|
110
111
|
|
tikzplotly/_histogram.py
CHANGED
|
@@ -50,6 +50,27 @@ def formalize_data(data, axis:Axis, row_sep="\\\\"):
|
|
|
50
50
|
|
|
51
51
|
return data_str
|
|
52
52
|
|
|
53
|
+
def treat_histnorm(histnorm: str, hist_options: dict):
|
|
54
|
+
"""Handle the normalization option of the histogram
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
histnorm : str
|
|
59
|
+
The normalization mode for the histogram.
|
|
60
|
+
hist_options : dict
|
|
61
|
+
Dictionary to store histogram options.
|
|
62
|
+
"""
|
|
63
|
+
if histnorm in ("percent", "probability", "density"):
|
|
64
|
+
warn(
|
|
65
|
+
f"Sorry, I did not find an equivalent for histnorm='{histnorm}' in TikZ. "
|
|
66
|
+
"If you need this feature implemented, please open an issue, if possible with a MWE pgfplots code "
|
|
67
|
+
"that would plot this :).\nFor now, the histogram will be plotted without normalization "
|
|
68
|
+
"(as if histnorm='probability density')."
|
|
69
|
+
)
|
|
70
|
+
hist_options["density"] = None
|
|
71
|
+
elif histnorm in ("probability density", ):
|
|
72
|
+
hist_options["density"] = None
|
|
73
|
+
|
|
53
74
|
def draw_histogram(trace, axis: Axis, colors_set, row_sep="\\\\"):
|
|
54
75
|
"""
|
|
55
76
|
Draw a histogram and return the TikZ code.
|
|
@@ -79,7 +100,8 @@ def draw_histogram(trace, axis: Axis, colors_set, row_sep="\\\\"):
|
|
|
79
100
|
|
|
80
101
|
code = ""
|
|
81
102
|
|
|
82
|
-
plot_options = {
|
|
103
|
+
plot_options = {}
|
|
104
|
+
plot_options["hist"] = None
|
|
83
105
|
type_options = {"row sep": row_sep, "y index": 0}
|
|
84
106
|
hist_options = {}
|
|
85
107
|
|
|
@@ -92,36 +114,15 @@ def draw_histogram(trace, axis: Axis, colors_set, row_sep="\\\\"):
|
|
|
92
114
|
axis.add_option("x filter/.expression", "rawy")
|
|
93
115
|
axis.add_option("y filter/.expression", "rawx")
|
|
94
116
|
hist_options["handler/.style"] = "{xbar interval}"
|
|
95
|
-
|
|
117
|
+
else: # trace.x and trace.y are both empty
|
|
118
|
+
warn("Empty histogram. Returning no plot")
|
|
119
|
+
return ""
|
|
96
120
|
|
|
97
121
|
|
|
98
122
|
if trace.nbinsx is not None:
|
|
99
123
|
hist_options["bins"] = trace.nbinsx
|
|
100
124
|
|
|
101
|
-
|
|
102
|
-
warn(
|
|
103
|
-
f"Sorry, I did not find an equivalent for histnorm='{trace.histnorm}' in TikZ. "
|
|
104
|
-
"If you need this feature implemented, please open an issue, if possible with a MWE pgfplots code "
|
|
105
|
-
"that would plot this :).\nFor now, the histogram will be plotted without normalization "
|
|
106
|
-
"(as if histnorm='probability density')."
|
|
107
|
-
)
|
|
108
|
-
hist_options["density"] = None
|
|
109
|
-
elif trace.histnorm == "probability":
|
|
110
|
-
warn(
|
|
111
|
-
f"Sorry, I did not find an equivalent for histnorm='{trace.histnorm}' in TikZ. "
|
|
112
|
-
"If you need this feature implemented, please open an issue, if possible with a MWE pgfplots code that would plot this :).\n"
|
|
113
|
-
"For now, the histogram will be plotted without normalization (as if histnorm='probability density')."
|
|
114
|
-
)
|
|
115
|
-
hist_options["density"] = None
|
|
116
|
-
elif trace.histnorm == "density":
|
|
117
|
-
warn(
|
|
118
|
-
f"Sorry, I did not find an equivalent for histnorm='{trace.histnorm}' in TikZ. "
|
|
119
|
-
"If you need this feature implemented, please open an issue, if possible with a MWE pgfplots code that would plot this :).\n"
|
|
120
|
-
"For now, the histogram will be plotted without normalization (as if histnorm='probability density')."
|
|
121
|
-
)
|
|
122
|
-
hist_options["density"] = None
|
|
123
|
-
elif trace.histnorm == "probability density":
|
|
124
|
-
hist_options["density"] = None
|
|
125
|
+
treat_histnorm(trace.histnorm, hist_options)
|
|
125
126
|
|
|
126
127
|
if trace.cumulative.enabled:
|
|
127
128
|
hist_options["cumulative"] = None
|
|
@@ -152,5 +153,4 @@ def draw_histogram(trace, axis: Axis, colors_set, row_sep="\\\\"):
|
|
|
152
153
|
code += tex_addplot(data_str, plot_type = "table",
|
|
153
154
|
options = option_dict_to_str(plot_options), type_options=option_dict_to_str(type_options))
|
|
154
155
|
|
|
155
|
-
|
|
156
156
|
return code
|
tikzplotly/_polar.py
CHANGED
|
@@ -7,7 +7,7 @@ from ._axis import Axis
|
|
|
7
7
|
from ._utils import option_dict_to_str
|
|
8
8
|
from ._tex import tex_addplot
|
|
9
9
|
from ._color import convert_color
|
|
10
|
-
from .
|
|
10
|
+
from ._data_container import DataContainer
|
|
11
11
|
|
|
12
12
|
def get_polar_coord(trace, axis: Axis, data_container: DataContainer):
|
|
13
13
|
"""Get polar coordinates from the trace
|
tikzplotly/_save.py
CHANGED
|
@@ -19,7 +19,7 @@ from ._polar import get_polar_coord, draw_scatterpolar
|
|
|
19
19
|
from ._axis import Axis
|
|
20
20
|
from ._color import convert_color
|
|
21
21
|
from ._annotations import str_from_annotation
|
|
22
|
-
from .
|
|
22
|
+
from ._data_container import DataContainer
|
|
23
23
|
from ._utils import sanitize_tex_text, sanitize_text
|
|
24
24
|
|
|
25
25
|
|
|
@@ -78,13 +78,13 @@ def get_tikz_code(
|
|
|
78
78
|
|
|
79
79
|
# If x is textual => symbolic x coords
|
|
80
80
|
if all(isinstance(v, str) for v in trace.x):
|
|
81
|
-
sanitized_trace_x = [sanitize_text(x, keep_space=-1) for x in trace.x]
|
|
81
|
+
sanitized_trace_x = [sanitize_text(str(x), keep_space=-1) for x in trace.x]
|
|
82
82
|
axis.add_option("symbolic x coords", "{" + ",".join(sanitized_trace_x) + "}")
|
|
83
83
|
axis.add_option("xtick", "data")
|
|
84
84
|
|
|
85
85
|
# If y is textual => symbolic y coords
|
|
86
86
|
if all(isinstance(v, str) for v in trace.y):
|
|
87
|
-
sanitized_trace_y = [sanitize_text(y, keep_space=-1) for y in trace.y]
|
|
87
|
+
sanitized_trace_y = [sanitize_text(str(y), keep_space=-1) for y in trace.y]
|
|
88
88
|
axis.add_option("symbolic y coords", "{" + ",".join(sanitized_trace_y) + "}")
|
|
89
89
|
axis.add_option("ytick", "data")
|
|
90
90
|
|
|
@@ -173,7 +173,7 @@ def get_tikz_code(
|
|
|
173
173
|
if hasattr(figure_layout.scene, "title") and getattr(figure_layout.scene.title, "text", None):
|
|
174
174
|
axis.add_option("title", f"{{{sanitize_tex_text(figure_layout.scene.title.text)}}}")
|
|
175
175
|
|
|
176
|
-
data_name_macro
|
|
176
|
+
data_name_macro = data_container.add_data3d(trace.x, trace.y, trace.z, trace.name)
|
|
177
177
|
data_str.append(draw_scatter3d(data_name_macro, trace, colors_set))
|
|
178
178
|
|
|
179
179
|
if trace.name and trace['showlegend'] is not False:
|
tikzplotly/_scatter.py
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Provides functionality to convert Plotly scatter traces into TikZ/PGFPlots code for LaTeX documents.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from warnings import warn
|
|
6
5
|
import numpy as np
|
|
7
6
|
from ._tex import tex_addplot, tex_add_text
|
|
8
7
|
from ._color import convert_color
|
|
9
|
-
from ._marker import marker_symbol_to_tex
|
|
10
8
|
from ._dash import DASH_PATTERN
|
|
11
9
|
from ._axis import Axis
|
|
12
10
|
from ._data import data_type
|
|
11
|
+
from ._trace_utils import configure_marker_options, finalize_marker_options
|
|
13
12
|
from ._utils import px_to_pt, option_dict_to_str
|
|
14
13
|
|
|
14
|
+
|
|
15
15
|
def draw_scatter2d(data_name, scatter, y_name, axis: Axis, color_set):
|
|
16
16
|
"""Get code for a scatter trace.
|
|
17
17
|
|
|
@@ -53,15 +53,8 @@ def draw_scatter2d(data_name, scatter, y_name, axis: Axis, color_set):
|
|
|
53
53
|
options_dict = {}
|
|
54
54
|
mark_option_dict = {}
|
|
55
55
|
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
symbol, symbol_options = marker_symbol_to_tex(marker.symbol)
|
|
59
|
-
options_dict["mark"] = symbol
|
|
60
|
-
options_dict["only marks"] = None
|
|
61
|
-
if symbol_options is not None:
|
|
62
|
-
mark_option_dict[symbol_options[0]] = symbol_options[1]
|
|
63
|
-
else:
|
|
64
|
-
options_dict["only marks"] = None
|
|
56
|
+
if "markers" in mode:
|
|
57
|
+
configure_marker_options(mode, marker, options_dict, mark_option_dict, color_set)
|
|
65
58
|
|
|
66
59
|
if scatter.marker.size is not None:
|
|
67
60
|
options_dict["mark size"] = px_to_pt(marker.size)
|
|
@@ -71,14 +64,7 @@ def draw_scatter2d(data_name, scatter, y_name, axis: Axis, color_set):
|
|
|
71
64
|
mark_option_dict["solid"] = None
|
|
72
65
|
mark_option_dict["fill"] = convert_color(scatter.marker.color)[0]
|
|
73
66
|
|
|
74
|
-
if (
|
|
75
|
-
if line.color is not None:
|
|
76
|
-
color_set.add(convert_color(line.color)[:3])
|
|
77
|
-
mark_option_dict["draw"] = convert_color(line.color)[0]
|
|
78
|
-
if line.width is not None:
|
|
79
|
-
mark_option_dict["line width"] = px_to_pt(line.width)
|
|
80
|
-
|
|
81
|
-
if (angle:=scatter.marker.angle) is not None:
|
|
67
|
+
if (angle := scatter.marker.angle) is not None:
|
|
82
68
|
mark_option_dict["rotate"] = angle
|
|
83
69
|
|
|
84
70
|
if (opacity := scatter.opacity) is not None:
|
|
@@ -86,22 +72,7 @@ def draw_scatter2d(data_name, scatter, y_name, axis: Axis, color_set):
|
|
|
86
72
|
if (opacity := scatter.marker.opacity) is not None:
|
|
87
73
|
mark_option_dict["opacity"] = np.round(opacity, 2)
|
|
88
74
|
|
|
89
|
-
|
|
90
|
-
mark_options = option_dict_to_str(mark_option_dict)
|
|
91
|
-
options_dict["mark options"] = f"{{{mark_options}}}"
|
|
92
|
-
|
|
93
|
-
elif mode == "lines":
|
|
94
|
-
options_dict["mark"] = "none"
|
|
95
|
-
|
|
96
|
-
elif "lines" in mode and "markers" in mode:
|
|
97
|
-
if marker.symbol is not None:
|
|
98
|
-
symbol, symbol_options = marker_symbol_to_tex(marker.symbol)
|
|
99
|
-
options_dict["mark"] = symbol
|
|
100
|
-
if symbol_options is not None:
|
|
101
|
-
mark_option_dict[symbol_options[0]] = symbol_options[1]
|
|
102
|
-
|
|
103
|
-
else:
|
|
104
|
-
warn(f"Scatter : Mode {mode} is not supported yet.")
|
|
75
|
+
finalize_marker_options(mode, options_dict, mark_option_dict, "Scatter")
|
|
105
76
|
|
|
106
77
|
if scatter.line.width is not None:
|
|
107
78
|
options_dict["line width"] = px_to_pt(scatter.line.width)
|
|
@@ -110,7 +81,6 @@ def draw_scatter2d(data_name, scatter, y_name, axis: Axis, color_set):
|
|
|
110
81
|
if scatter.connectgaps in [False, None] and None in scatter.x:
|
|
111
82
|
options_dict["unbounded coords"] = "jump"
|
|
112
83
|
|
|
113
|
-
|
|
114
84
|
if scatter.line.color is not None:
|
|
115
85
|
options_dict["color"] = convert_color(scatter.line.color)[0]
|
|
116
86
|
if "mark" in mode:
|
tikzplotly/_scatter3d.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Provides functionality to convert Plotly 3D scatter traces into TikZ/PGFPlots code for LaTeX documents.
|
|
3
3
|
"""
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import numpy as np
|
|
6
6
|
from ._color import convert_color
|
|
7
|
-
from .
|
|
7
|
+
from ._trace_utils import configure_marker_options, finalize_marker_options
|
|
8
8
|
from ._utils import px_to_pt, option_dict_to_str
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
def draw_scatter3d(data_name, scatter, color_set):
|
|
11
12
|
"""
|
|
12
13
|
Get code for a scatter3d trace.
|
|
@@ -28,16 +29,8 @@ def draw_scatter3d(data_name, scatter, color_set):
|
|
|
28
29
|
options_dict = {}
|
|
29
30
|
mark_option_dict = {}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if marker.symbol is not None:
|
|
34
|
-
symbol, symbol_options = marker_symbol_to_tex(marker.symbol)
|
|
35
|
-
options_dict["mark"] = symbol
|
|
36
|
-
options_dict["only marks"] = None
|
|
37
|
-
if symbol_options is not None:
|
|
38
|
-
mark_option_dict[symbol_options[0]] = symbol_options[1]
|
|
39
|
-
else:
|
|
40
|
-
options_dict["only marks"] = None
|
|
32
|
+
if "markers" in mode:
|
|
33
|
+
configure_marker_options(mode, marker, options_dict, mark_option_dict, color_set)
|
|
41
34
|
|
|
42
35
|
if marker.size is not None:
|
|
43
36
|
size = marker.size
|
|
@@ -53,34 +46,12 @@ def draw_scatter3d(data_name, scatter, color_set):
|
|
|
53
46
|
mark_option_dict["solid"] = None
|
|
54
47
|
mark_option_dict["fill"] = convert_color(c)[0]
|
|
55
48
|
|
|
56
|
-
if (line := marker.line) is not None:
|
|
57
|
-
if line.color is not None:
|
|
58
|
-
color_set.add(convert_color(line.color)[:3])
|
|
59
|
-
mark_option_dict["draw"] = convert_color(line.color)[0]
|
|
60
|
-
if line.width is not None:
|
|
61
|
-
mark_option_dict["line width"] = px_to_pt(line.width)
|
|
62
|
-
|
|
63
49
|
if (opacity := scatter.opacity) is not None:
|
|
64
50
|
options_dict["opacity"] = opacity
|
|
65
51
|
if (opacity := marker.opacity) is not None:
|
|
66
52
|
mark_option_dict["opacity"] = opacity
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
mark_options = option_dict_to_str(mark_option_dict)
|
|
70
|
-
options_dict["mark options"] = f"{{{mark_options}}}"
|
|
71
|
-
|
|
72
|
-
elif mode == "lines":
|
|
73
|
-
options_dict["mark"] = "none"
|
|
74
|
-
|
|
75
|
-
elif "lines" in mode and "markers" in mode:
|
|
76
|
-
if marker.symbol is not None:
|
|
77
|
-
symbol, symbol_options = marker_symbol_to_tex(marker.symbol)
|
|
78
|
-
options_dict["mark"] = symbol
|
|
79
|
-
if symbol_options is not None:
|
|
80
|
-
mark_option_dict[symbol_options[0]] = symbol_options[1]
|
|
81
|
-
|
|
82
|
-
else:
|
|
83
|
-
warn(f"Scatter3d : Mode {mode} is not supported yet.")
|
|
54
|
+
finalize_marker_options(mode, options_dict, mark_option_dict, "Scatter3d")
|
|
84
55
|
|
|
85
56
|
if scatter.line is not None:
|
|
86
57
|
if scatter.line.width is not None:
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Shared helpers for Plotly trace to TikZ conversion."""
|
|
2
|
+
|
|
3
|
+
from warnings import warn
|
|
4
|
+
|
|
5
|
+
from ._color import convert_color
|
|
6
|
+
from ._marker import marker_symbol_to_tex
|
|
7
|
+
from ._utils import px_to_pt, option_dict_to_str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def configure_marker_options(mode, marker, options_dict, mark_option_dict, color_set):
|
|
11
|
+
"""Populate marker-related TikZ options for scatter-like traces.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
mode
|
|
16
|
+
Plotly trace mode string (for example ``markers`` or ``markers+lines``).
|
|
17
|
+
marker
|
|
18
|
+
Plotly marker object from the trace.
|
|
19
|
+
options_dict
|
|
20
|
+
Dictionary collecting top-level PGFPlots options.
|
|
21
|
+
mark_option_dict
|
|
22
|
+
Dictionary collecting nested ``mark options`` for PGFPlots.
|
|
23
|
+
color_set
|
|
24
|
+
Set used to track colors that must be defined in the LaTeX output.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
if marker.symbol is not None:
|
|
28
|
+
symbol, symbol_options = marker_symbol_to_tex(marker.symbol)
|
|
29
|
+
options_dict["mark"] = symbol
|
|
30
|
+
if "lines" not in mode:
|
|
31
|
+
options_dict["only marks"] = None
|
|
32
|
+
if symbol_options is not None:
|
|
33
|
+
mark_option_dict[symbol_options[0]] = symbol_options[1]
|
|
34
|
+
elif "lines" not in mode:
|
|
35
|
+
options_dict["only marks"] = None
|
|
36
|
+
|
|
37
|
+
if (line := marker.line) is not None:
|
|
38
|
+
if line.color is not None:
|
|
39
|
+
color = convert_color(line.color)
|
|
40
|
+
color_set.add(color[:3])
|
|
41
|
+
mark_option_dict["draw"] = color[0]
|
|
42
|
+
if line.width is not None:
|
|
43
|
+
mark_option_dict["line width"] = px_to_pt(line.width)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def finalize_marker_options(mode, options_dict, mark_option_dict, trace_name):
|
|
47
|
+
"""Finalize marker options and handle unsupported modes.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
mode
|
|
52
|
+
Plotly trace mode string.
|
|
53
|
+
options_dict
|
|
54
|
+
Dictionary collecting top-level PGFPlots options.
|
|
55
|
+
mark_option_dict
|
|
56
|
+
Dictionary collecting nested ``mark options`` for PGFPlots.
|
|
57
|
+
trace_name
|
|
58
|
+
Name used in warnings to identify the trace kind.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
if "markers" in mode:
|
|
62
|
+
if mark_option_dict:
|
|
63
|
+
mark_options = option_dict_to_str(mark_option_dict)
|
|
64
|
+
options_dict["mark options"] = f"{{{mark_options}}}"
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
if mode == "lines":
|
|
68
|
+
options_dict["mark"] = "none"
|
|
69
|
+
else:
|
|
70
|
+
warn(f"{trace_name} : Mode {mode} is not supported yet.")
|
tikzplotly/_utils.py
CHANGED
|
@@ -93,18 +93,10 @@ def sanitize_char(ch: str, keep_space: int = 0) -> str:
|
|
|
93
93
|
if ch == "@":
|
|
94
94
|
return "at"
|
|
95
95
|
if ch == " ":
|
|
96
|
-
if keep_space == 1
|
|
97
|
-
return " "
|
|
98
|
-
if keep_space == 0:
|
|
99
|
-
return "_"
|
|
100
|
-
return ""
|
|
96
|
+
return " " if keep_space == 1 else "_" if keep_space == 0 else ""
|
|
101
97
|
if ch in "[]{}= ":
|
|
102
98
|
return f"x{ord(ch):x}"
|
|
103
|
-
|
|
104
|
-
if ord(ch) > 127:
|
|
105
|
-
return f"x{ord(ch):x}"
|
|
106
|
-
# if not printable, return hex
|
|
107
|
-
if not ch.isprintable():
|
|
99
|
+
if ord(ch) > 127 or not ch.isprintable(): # not ascii or not printable: return hex
|
|
108
100
|
return f"x{ord(ch):x}"
|
|
109
101
|
return ch
|
|
110
102
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tikzplotly
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
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)
|
|
@@ -44,6 +44,7 @@ License-File: LICENSE
|
|
|
44
44
|
Requires-Dist: numpy
|
|
45
45
|
Requires-Dist: plotly
|
|
46
46
|
Requires-Dist: pillow
|
|
47
|
+
Requires-Dist: kaleido
|
|
47
48
|
Provides-Extra: dev
|
|
48
49
|
Requires-Dist: pandas; extra == "dev"
|
|
49
50
|
Dynamic: license-file
|
|
@@ -5,26 +5,27 @@ tests/test_line_charts.py,sha256=cyiVuUyH1lZ51p_JVcP3xjLlEEbSm_iD5gj6F4p8DUo,158
|
|
|
5
5
|
tests/test_markers.py,sha256=g3ioyRqRh__VyKGET2RpCiEmLnQAztsYF5drqTq3idU,11555
|
|
6
6
|
tests/test_polar.py,sha256=xvVx-Af855-eIw5Kmq1ApHHCv9hGr2WF6HuaN4XMZms,17244
|
|
7
7
|
tests/test_scatter3d.py,sha256=yfieEogsVS2Wa5DgPJzIvsW2jz8yaPhkVU_nDrBWVTg,4359
|
|
8
|
-
tikzplotly/__about__.py,sha256=
|
|
8
|
+
tikzplotly/__about__.py,sha256=W0m95bZPSmPKyrbh5zZGO071YHBbLsK0LQxvES50b7c,204
|
|
9
9
|
tikzplotly/__init__.py,sha256=PrbDMOviELxIm9nyXS6Qk56-YhuTb-bAn_0BuY2rHLE,552
|
|
10
10
|
tikzplotly/_annotations.py,sha256=r3MPz_Ocx3oQzsCuqKT3pdX1ijb3-LAmYHpLPLulASI,3108
|
|
11
11
|
tikzplotly/_axis.py,sha256=t-v97WnUJMq3ulRi_1E9r0Sv3glodVtqmzIWUftwFlQ,8062
|
|
12
12
|
tikzplotly/_bar.py,sha256=m4Hc4GR-bnEdrS3tU7VgZqCz0mdA9ENfBjGAvjavpA8,3263
|
|
13
|
-
tikzplotly/_color.py,sha256=
|
|
13
|
+
tikzplotly/_color.py,sha256=hnBMZsVBs1M6YV1_hqquZYuLCO-fBEUaxtwD6cd-fMQ,41213
|
|
14
14
|
tikzplotly/_dash.py,sha256=8hOaqzMDRcikD2HNWc18fzJm2Lvoq3eo3Tu8n0gAqvE,228
|
|
15
15
|
tikzplotly/_data.py,sha256=t3TG0jvc_cjR84Ug04OUDyfF0hKFD_xKOgbgb1Xz-8M,1847
|
|
16
|
-
tikzplotly/
|
|
17
|
-
tikzplotly/_heatmap.py,sha256=
|
|
18
|
-
tikzplotly/_histogram.py,sha256=
|
|
16
|
+
tikzplotly/_data_container.py,sha256=G2mE8tgRfZV4pzNGWa23JCo4e63j_Rpm0wszXlunvAU,7040
|
|
17
|
+
tikzplotly/_heatmap.py,sha256=tUxs4gEaqi0TyY5TIInTJa_APUQPTnV0RXuDkWQ0N7w,5095
|
|
18
|
+
tikzplotly/_histogram.py,sha256=PH0c1ZFU7VnJoWD6NIsF4VJAWReWZhGwNm1iZs7OXu0,5112
|
|
19
19
|
tikzplotly/_marker.py,sha256=L5E_-fb4Fkv231dBmA72byAZeYPeVuKOFZIYTyLbMrs,11839
|
|
20
|
-
tikzplotly/_polar.py,sha256=
|
|
21
|
-
tikzplotly/_save.py,sha256=
|
|
22
|
-
tikzplotly/_scatter.py,sha256=
|
|
23
|
-
tikzplotly/_scatter3d.py,sha256=
|
|
20
|
+
tikzplotly/_polar.py,sha256=qhza1x53wgCjAafGIt1ncdRfKFLIlJJE5cvoR80TrIs,7792
|
|
21
|
+
tikzplotly/_save.py,sha256=YuR0gqVtK6EhCyYoMxbVEHvzCMofEILV-42Ulp8iHU4,10219
|
|
22
|
+
tikzplotly/_scatter.py,sha256=Eu9RhAUUZHH4q7l6NWayzVsJh33vPkCvWbCnR4vwUME,3538
|
|
23
|
+
tikzplotly/_scatter3d.py,sha256=Fd3Rx0d8o-CefPSU8CyGD_BNJ7wB8yr_QbaKuWEG1qo,2389
|
|
24
24
|
tikzplotly/_tex.py,sha256=LlsMRncCzmGJGO9OtgKyDMEnVA7WKvLptqh1yM5LdmQ,6555
|
|
25
|
-
tikzplotly/
|
|
26
|
-
tikzplotly
|
|
27
|
-
tikzplotly-0.2.
|
|
28
|
-
tikzplotly-0.2.
|
|
29
|
-
tikzplotly-0.2.
|
|
30
|
-
tikzplotly-0.2.
|
|
25
|
+
tikzplotly/_trace_utils.py,sha256=NyQYkxtrRLHuA9pjfNqUihW3rYvdwvDo8Kj9IEaJo5I,2316
|
|
26
|
+
tikzplotly/_utils.py,sha256=vGvqlwKzv_R6euq1kGp5nmET9ACxy17P72Fv5cBx1Dc,6241
|
|
27
|
+
tikzplotly-0.2.2.dist-info/licenses/LICENSE,sha256=cjxM8VJ_qnjUVKoOndGip4HgyyElZZI8Hk8g3rXEFf8,1080
|
|
28
|
+
tikzplotly-0.2.2.dist-info/METADATA,sha256=YX9jbyjsA7-d1rGp5_Kil0v4O7-r9X7syJqgvINqQ0M,6643
|
|
29
|
+
tikzplotly-0.2.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
30
|
+
tikzplotly-0.2.2.dist-info/top_level.txt,sha256=NSVJ1u8Bv6DVRb_y_Roui9D7tVh2XYDaGVjSbZyTrH4,17
|
|
31
|
+
tikzplotly-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|