tikzplot42 0.2.8__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.
- tikzplot/__init__.py +5 -0
- tikzplot/__init__.pyi +5 -0
- tikzplot/axes.py +717 -0
- tikzplot/axes.pyi +445 -0
- tikzplot/axes3d.py +566 -0
- tikzplot/colorbar.py +261 -0
- tikzplot/colorbar.pyi +128 -0
- tikzplot/colors.py +58 -0
- tikzplot/colors.pyi +1 -0
- tikzplot/config.py +101 -0
- tikzplot/config.pyi +95 -0
- tikzplot/elements.py +641 -0
- tikzplot/elements.pyi +11 -0
- tikzplot/figure.py +285 -0
- tikzplot/figure.pyi +27 -0
- tikzplot/latex_special.py +62 -0
- tikzplot/plots.py +175 -0
- tikzplot/plots.pyi +314 -0
- tikzplot/py.typed +0 -0
- tikzplot/state.py +24 -0
- tikzplot/state.pyi +3 -0
- tikzplot42-0.2.8.dist-info/METADATA +780 -0
- tikzplot42-0.2.8.dist-info/RECORD +26 -0
- tikzplot42-0.2.8.dist-info/WHEEL +5 -0
- tikzplot42-0.2.8.dist-info/licenses/LICENSE +674 -0
- tikzplot42-0.2.8.dist-info/top_level.txt +1 -0
tikzplot/plots.pyi
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# plots.pyi
|
|
2
|
+
|
|
3
|
+
from typing import Any, Optional, Tuple, Union, Sequence, Literal
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from .config import TikzConfig as TikzConfig
|
|
7
|
+
from .figure import Figure as Figure
|
|
8
|
+
from .state import main_name as main_name, next_show_num as next_show_num
|
|
9
|
+
from .axes import Axes
|
|
10
|
+
|
|
11
|
+
ArrayLike = Union[Sequence[float], np.ndarray]
|
|
12
|
+
ColorLike = Union[str, Sequence[float]]
|
|
13
|
+
LineStyle = Literal["-", "--", "-.", ":", "solid", "dashed", "dashdot", "none", ""]
|
|
14
|
+
MarkerStyle = Literal["o", "s", "^", "v", "x", "+", ".", "*", "None", ""]
|
|
15
|
+
|
|
16
|
+
# --- Figure / Axes creation ---
|
|
17
|
+
|
|
18
|
+
def figure(*, figsize: Optional[Tuple[float, float]] = ...) -> Figure:
|
|
19
|
+
"""
|
|
20
|
+
Create a new figure.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
figsize : tuple of float, optional
|
|
25
|
+
Figure size in inches (width, height).
|
|
26
|
+
"""
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
def subplot(
|
|
30
|
+
nrows: int,
|
|
31
|
+
ncols: int,
|
|
32
|
+
index: int,
|
|
33
|
+
sharex: Optional[Axes] = ...,
|
|
34
|
+
sharey: Optional[Axes] = ...
|
|
35
|
+
) -> Axes:
|
|
36
|
+
"""
|
|
37
|
+
Create a subplot and make it current.
|
|
38
|
+
"""
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
def subplots(
|
|
42
|
+
nrows: int = 1,
|
|
43
|
+
ncols: int = 1,
|
|
44
|
+
sharex: Optional[Axes] = ...,
|
|
45
|
+
sharey: Optional[Axes] = ...,
|
|
46
|
+
**kwargs: Any
|
|
47
|
+
) -> Tuple[Figure, Union[Axes, np.ndarray]]:
|
|
48
|
+
"""
|
|
49
|
+
Create a figure and a set of subplots.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
fig : Figure
|
|
54
|
+
ax : Axes or ndarray of Axes
|
|
55
|
+
- Single Axes if nrows*ncols == 1
|
|
56
|
+
- 1D array if one dimension is 1
|
|
57
|
+
- 2D array otherwise
|
|
58
|
+
"""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# --- Axis label / limits ---
|
|
63
|
+
|
|
64
|
+
def xlabel(label: str) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Set x-axis label.
|
|
67
|
+
"""
|
|
68
|
+
...
|
|
69
|
+
|
|
70
|
+
def ylabel(label: str) -> None:
|
|
71
|
+
"""
|
|
72
|
+
Set y-axis label.
|
|
73
|
+
"""
|
|
74
|
+
...
|
|
75
|
+
|
|
76
|
+
def title(text: str) -> None:
|
|
77
|
+
"""
|
|
78
|
+
Set plot title.
|
|
79
|
+
"""
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
def xlim(*args: Any, left: Optional[float] = ..., right: Optional[float] = ...) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Set x-axis limit(-s). Set as tuple or as kwargs (left, right).
|
|
85
|
+
|
|
86
|
+
"""
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
def ylim(*args: Any, bottom: Optional[float] = ..., top: Optional[float] = ...) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Set y-axis limit(-s). Set as tuple or as kwargs (top, bottom).
|
|
92
|
+
|
|
93
|
+
"""
|
|
94
|
+
...
|
|
95
|
+
|
|
96
|
+
def xscale(*args: Any, base: Optional[float] = ...) -> None:
|
|
97
|
+
"""
|
|
98
|
+
Set x-axis scale (to log).
|
|
99
|
+
"""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
def yscale(*args: Any, base: Optional[float] = ...) -> None:
|
|
103
|
+
"""
|
|
104
|
+
Set y-axis scale (to log).
|
|
105
|
+
"""
|
|
106
|
+
...
|
|
107
|
+
|
|
108
|
+
def xticks(ticks: Sequence[float], labels: Optional[Sequence[str]] = ...) -> None:
|
|
109
|
+
"""
|
|
110
|
+
Set x-axis ticks and their labels.
|
|
111
|
+
"""
|
|
112
|
+
...
|
|
113
|
+
|
|
114
|
+
def yticks(ticks: Sequence[float], labels: Optional[Sequence[str]] = ...) -> None:
|
|
115
|
+
"""
|
|
116
|
+
Set y-axis ticks and their labels.
|
|
117
|
+
"""
|
|
118
|
+
...
|
|
119
|
+
|
|
120
|
+
def grid(self, visible: bool = True, which: Literal["major","minor","both"] = "major", alpha: Optional[float] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ...,
|
|
121
|
+
linestyle: Optional[LineStyle] = ..., ls: Optional[LineStyle] = ..., linewidth: Optional[float]= ..., lw: Optional[float] = ...) -> None:
|
|
122
|
+
"""
|
|
123
|
+
Set grid.
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
visible: bool, default True
|
|
128
|
+
Show grid
|
|
129
|
+
which: {"major", "minor", "both"}, default "major"
|
|
130
|
+
Grid selector
|
|
131
|
+
alpha: float, optional
|
|
132
|
+
Opacity
|
|
133
|
+
color or c: all matplotlib color formats (without X11/xkcd), optional
|
|
134
|
+
Grid color: RGB/RGBA (tuple), HEX (str), grayscale (float), single-char (str), name (str), default cycle ("CX", X int), none for invisible
|
|
135
|
+
linestyle or ls: str, optional
|
|
136
|
+
Grid line style
|
|
137
|
+
linewidth or lw: float, optional
|
|
138
|
+
Grid line width in pt
|
|
139
|
+
"""
|
|
140
|
+
def set_minorticks_num(num: int) -> None:
|
|
141
|
+
"""
|
|
142
|
+
Set number of minor ticks between major ticks.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
num: int
|
|
147
|
+
Number of minor ticks between major ticks.
|
|
148
|
+
"""
|
|
149
|
+
def legend(*args: Any, loc: Optional[Union[int,str,Tuple[float,float]]] = ...) -> None:
|
|
150
|
+
"""
|
|
151
|
+
Show legend for the selected axis.
|
|
152
|
+
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
loc: int, str or tuple, optional
|
|
156
|
+
Location of legend (as in matplotlib: 1 - upper right, 2 - upper left, ... or with tuple of relative coordinates).
|
|
157
|
+
"""
|
|
158
|
+
...
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# --- Plotting (verbatim docstrings) ---
|
|
162
|
+
|
|
163
|
+
def plot(
|
|
164
|
+
x: ArrayLike = ..., y: ArrayLike = ..., fmt: Optional[str] = ...,
|
|
165
|
+
*,
|
|
166
|
+
alpha: Optional[float] = ...,
|
|
167
|
+
color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ...,
|
|
168
|
+
linestyle: Optional[LineStyle] = ..., ls: Optional[LineStyle] = ...,
|
|
169
|
+
linewidth: Optional[float]= ..., lw: Optional[float] = ...,
|
|
170
|
+
marker: Optional[MarkerStyle] = ...,
|
|
171
|
+
markersize: Optional[float] = ..., ms: Optional[float] = ...,
|
|
172
|
+
label: Optional[str] = ...
|
|
173
|
+
) -> None:
|
|
174
|
+
"""
|
|
175
|
+
Draw a general plot to the selected axis.
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
x,y : ArrayLike or float
|
|
180
|
+
Datapoints
|
|
181
|
+
|
|
182
|
+
fmt: str, optional
|
|
183
|
+
Style
|
|
184
|
+
|
|
185
|
+
alpha: float, optional
|
|
186
|
+
Opacity
|
|
187
|
+
|
|
188
|
+
color or c: all matplotlib color formats (without X11/xkcd), optional
|
|
189
|
+
color of line and markers: RGB/RGBA (tuple), HEX (str), grayscale (float), single-char (str), name (str), default cycle ("CX", X int), none for invisible
|
|
190
|
+
|
|
191
|
+
label: str, optional
|
|
192
|
+
Legned entry
|
|
193
|
+
|
|
194
|
+
linestyle or ls: str, optional
|
|
195
|
+
Line style
|
|
196
|
+
|
|
197
|
+
linewidth or lw: float, optional
|
|
198
|
+
Line width in pt
|
|
199
|
+
|
|
200
|
+
marker: str, optional
|
|
201
|
+
Marker type
|
|
202
|
+
|
|
203
|
+
markersize or ms: float, optional
|
|
204
|
+
Mark size in pt
|
|
205
|
+
"""
|
|
206
|
+
...
|
|
207
|
+
|
|
208
|
+
def scatter(
|
|
209
|
+
x: ArrayLike = ..., y: ArrayLike = ..., fmt: Optional[str] = ...,
|
|
210
|
+
*,
|
|
211
|
+
alpha: Optional[float] = ...,
|
|
212
|
+
color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ...,
|
|
213
|
+
marker: Optional[MarkerStyle] = ...,
|
|
214
|
+
markersize: Optional[float] = ..., ms: Optional[float] = ...,
|
|
215
|
+
label: Optional[str] = ...
|
|
216
|
+
) -> None:
|
|
217
|
+
"""
|
|
218
|
+
Draw a scatter plot to the selected axis.
|
|
219
|
+
|
|
220
|
+
Parameters
|
|
221
|
+
----------
|
|
222
|
+
x,y : ArrayLike or float
|
|
223
|
+
Datapoints
|
|
224
|
+
|
|
225
|
+
fmt: str, optional
|
|
226
|
+
Style
|
|
227
|
+
|
|
228
|
+
alpha: float, optional
|
|
229
|
+
Opacity
|
|
230
|
+
|
|
231
|
+
color or c: all matplotlib color formats (without X11/xkcd), optional
|
|
232
|
+
color of line and markers: RGB/RGBA (tuple), HEX (str), grayscale (float), single-char (str), name (str), default cycle ("CX", X int), none for invisible
|
|
233
|
+
|
|
234
|
+
label: str, optional
|
|
235
|
+
Legned entry
|
|
236
|
+
|
|
237
|
+
marker: str, optional
|
|
238
|
+
Marker type
|
|
239
|
+
|
|
240
|
+
markersize or ms: float, optional
|
|
241
|
+
Mark size in pt
|
|
242
|
+
"""
|
|
243
|
+
...
|
|
244
|
+
|
|
245
|
+
def semilogy(
|
|
246
|
+
x: ArrayLike = ..., y: ArrayLike = ..., base: Optional[float] = 10,
|
|
247
|
+
fmt: Optional[str] = ...,
|
|
248
|
+
*,
|
|
249
|
+
alpha: Optional[float] = ...,
|
|
250
|
+
color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ...,
|
|
251
|
+
linestyle: Optional[LineStyle] = ..., ls: Optional[LineStyle] = ...,
|
|
252
|
+
linewidth: Optional[float]= ..., lw: Optional[float] = ...,
|
|
253
|
+
marker: Optional[MarkerStyle] = ...,
|
|
254
|
+
markersize: Optional[float] = ..., ms: Optional[float] = ...,
|
|
255
|
+
label: Optional[str] = ...
|
|
256
|
+
) -> None:
|
|
257
|
+
"""
|
|
258
|
+
Draw a general plot to the selected axis and change the current y-axis into log mode.
|
|
259
|
+
|
|
260
|
+
Parameters
|
|
261
|
+
----------
|
|
262
|
+
x,y : ArrayLike or float
|
|
263
|
+
Datapoints
|
|
264
|
+
|
|
265
|
+
base: float, optional
|
|
266
|
+
Log basis, default 10
|
|
267
|
+
|
|
268
|
+
fmt: str, optional
|
|
269
|
+
Style
|
|
270
|
+
|
|
271
|
+
alpha: float, optional
|
|
272
|
+
Opacity
|
|
273
|
+
|
|
274
|
+
color or c: all matplotlib color formats (without X11/xkcd), optional
|
|
275
|
+
color of line and markers: RGB/RGBA (tuple), HEX (str), grayscale (float), single-char (str), name (str), default cycle ("CX", X int), none for invisible
|
|
276
|
+
|
|
277
|
+
label: str, optional
|
|
278
|
+
Legned entry
|
|
279
|
+
|
|
280
|
+
linestyle or ls: str, optional
|
|
281
|
+
Line style
|
|
282
|
+
|
|
283
|
+
linewidth or lw: float, optional
|
|
284
|
+
Line width in pt
|
|
285
|
+
|
|
286
|
+
marker: str, optional
|
|
287
|
+
Marker type
|
|
288
|
+
|
|
289
|
+
markersize or ms: float, optional
|
|
290
|
+
Mark size in pt
|
|
291
|
+
"""
|
|
292
|
+
...
|
|
293
|
+
|
|
294
|
+
# --- Output ---
|
|
295
|
+
|
|
296
|
+
def savefig(filename: str) -> None:
|
|
297
|
+
"""
|
|
298
|
+
Save figure to .tex/.tikz file.
|
|
299
|
+
|
|
300
|
+
If no extension is provided, '.tex' is appended.
|
|
301
|
+
"""
|
|
302
|
+
...
|
|
303
|
+
|
|
304
|
+
def show() -> None:
|
|
305
|
+
"""
|
|
306
|
+
Save figure to autogenerated filename and clear it.
|
|
307
|
+
"""
|
|
308
|
+
...
|
|
309
|
+
|
|
310
|
+
def clf() -> None:
|
|
311
|
+
"""
|
|
312
|
+
Clear current figure.
|
|
313
|
+
"""
|
|
314
|
+
...
|
tikzplot/py.typed
ADDED
|
File without changes
|
tikzplot/state.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import __main__
|
|
2
|
+
import os.path
|
|
3
|
+
|
|
4
|
+
_export_counter = 0
|
|
5
|
+
_show_counter = 0
|
|
6
|
+
_imshow_counter = 0
|
|
7
|
+
|
|
8
|
+
def next_export_num():
|
|
9
|
+
global _export_counter
|
|
10
|
+
_export_counter += 1
|
|
11
|
+
return _export_counter
|
|
12
|
+
|
|
13
|
+
def next_show_num():
|
|
14
|
+
global _show_counter
|
|
15
|
+
_show_counter += 1
|
|
16
|
+
return _show_counter
|
|
17
|
+
|
|
18
|
+
def _next_imshow_num():
|
|
19
|
+
global _imshow_counter
|
|
20
|
+
_imshow_counter += 1
|
|
21
|
+
return _imshow_counter
|
|
22
|
+
|
|
23
|
+
def main_name():
|
|
24
|
+
return os.path.split(getattr(__main__, '__file__', None))
|
tikzplot/state.pyi
ADDED