Skip to content

Commit a4c3621

Browse files
author
Gorshanov Vadim
committed
Allow only drawing every N'th dot in a path
This makes the output file much smaller and thus much easier for latex to compile. In a lot of cases, apparently, all the dots are not needed to produce smooth plots.
1 parent 19e76f8 commit a4c3621

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/tikzplotlib/_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def draw_pathcollection(data, obj):
303303

304304
plot_table = []
305305
plot_table.append(" ".join(labels) + "\n")
306-
for row in dd_strings:
306+
for row in dd_strings[::data["every n dot"]]:
307307
plot_table.append(" ".join(row) + "\n")
308308

309309
if data["externalize tables"]:

src/tikzplotlib/_save.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def get_tikz_code(
4040
float_format: str = ".15g",
4141
table_row_sep: str = "\n",
4242
flavor: str = "latex",
43+
every_n_dot: int = 1,
4344
):
4445
"""Main function. Here, the recursion into the image starts and the
4546
contents are picked up. The actual file gets written in this routine.
@@ -136,6 +137,9 @@ def get_tikz_code(
136137
Default is ``"latex"``.
137138
:type flavor: str
138139
140+
:param every_n_dot: if path is encountered, only draw every Nth dot
141+
:type every_n_dot: int
142+
139143
:returns: None
140144
141145
The following optional attributes of matplotlib's objects are recognized
@@ -176,6 +180,7 @@ def get_tikz_code(
176180
data["legend colors"] = []
177181
data["add axis environment"] = add_axis_environment
178182
data["show_info"] = show_info
183+
data["every n dot"] = every_n_dot
179184
# rectangle_legends is used to keep track of which rectangles have already
180185
# had \addlegendimage added. There should be only one \addlegenimage per
181186
# bar chart data series.

0 commit comments

Comments
 (0)