Skip to content

Commit d88bb1e

Browse files
authored
Merge pull request #399 from nschloe/fix-warning
Fix warning
2 parents 4acb140 + c5a2476 commit d88bb1e

7 files changed

+82
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<a href="https://github.com/nschloe/tikzplotlib"><img alt="tikzplotlib" src="https://nschloe.github.io/tikzplotlib/logo-tikzplotlib.svg" width="60%"></a>
3-
<p align="center">The artist formerly known as _matplotlib2tikz._</p>
3+
<p align="center">The artist formerly known as *matplotlib2tikz.*</p>
44
</p>
55

66
[![CircleCI](https://img.shields.io/circleci/project/github/nschloe/tikzplotlib/master.svg?style=flat-square)](https://circleci.com/gh/nschloe/tikzplotlib/tree/master)

test/refresh_reference_files.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,36 @@
88

99

1010
def _main():
11-
parser = argparse.ArgumentParser(description="Refresh the reference TeX files.")
12-
parser.add_argument("files", nargs="+", help="Files to refresh")
13-
args = parser.parse_args()
11+
parser = argparse.ArgumentParser(description="Refresh all reference TeX files.")
12+
parser.parse_args()
1413

1514
this_dir = os.path.dirname(os.path.abspath(__file__))
16-
exclude_list = ["test_rotated_labels.py", "test_deterministic_output.py"]
17-
18-
for filename in args.files:
19-
if filename in exclude_list:
20-
continue
21-
if filename.startswith("test_") and filename.endswith(".py"):
22-
spec = importlib.util.spec_from_file_location("plot", filename)
23-
module = importlib.util.module_from_spec(spec)
24-
spec.loader.exec_module(module)
25-
module.plot()
26-
27-
code = tpl.get_tikz_code(include_disclaimer=False, float_format=".8g")
28-
plt.close()
29-
30-
tex_filename = filename[:-3] + "_reference.tex"
31-
with open(os.path.join(this_dir, tex_filename), "w", encoding="utf8") as f:
32-
f.write(code)
15+
16+
test_files = [
17+
f
18+
for f in os.listdir(this_dir)
19+
if os.path.isfile(os.path.join(this_dir, f))
20+
and f[:5] == "test_"
21+
and f[-3:] == ".py"
22+
]
23+
test_modules = [f[:-3] for f in test_files]
24+
25+
# remove some edge cases
26+
test_modules.remove("test_rotated_labels")
27+
test_modules.remove("test_deterministic_output")
28+
test_modules.remove("test_cleanfigure")
29+
test_modules.remove("test_context")
30+
31+
for mod in test_modules:
32+
module = importlib.import_module(mod)
33+
module.plot()
34+
35+
code = tpl.get_tikz_code(include_disclaimer=False, float_format=".8g")
36+
plt.close()
37+
38+
tex_filename = mod + "_reference.tex"
39+
with open(os.path.join(this_dir, tex_filename), "w", encoding="utf8") as f:
40+
f.write(code)
3341

3442

3543
if __name__ == "__main__":

test/test_colorbars_reference.tex

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,65 +37,63 @@
3737
tick pos=left,
3838
x grid style={white!69.019608!black},
3939
xlabel={Discrete intervals, some other units},
40-
xmin=-0.05, xmax=1.05,
40+
xmin=0.65, xmax=8.35,
4141
xtick style={color=black},
42-
xtick={0,0.14285714,0.42857143,0.85714286,1},
42+
xtick={1,2,4,7,8},
4343
xticklabels={1,2,4,7,8},
44-
ymin=0, ymax=1
44+
ymin=1, ymax=8
4545
]
4646
\path [draw=white, fill=white, line width=0.004pt]
47-
(axis cs:-0.05,0.5)
48-
--(axis cs:0,0)
49-
--(axis cs:1,0)
50-
--(axis cs:1.05,0.5)
51-
--(axis cs:1.05,0.5)
47+
(axis cs:0.65,4.5)
5248
--(axis cs:1,1)
53-
--(axis cs:0,1)
54-
--(axis cs:-0.05,0.5)
49+
--(axis cs:8,1)
50+
--(axis cs:8.35,4.5)
51+
--(axis cs:8.35,4.5)
52+
--(axis cs:8,8)
53+
--(axis cs:1,8)
54+
--(axis cs:0.65,4.5)
5555
--cycle;
56-
\addplot graphics [includegraphics cmd=\pgfimage,xmin=-0.05, xmax=1.05, ymin=0, ymax=1] {tmp-001.png};
56+
\addplot graphics [includegraphics cmd=\pgfimage,xmin=0.65, xmax=8.35, ymin=1, ymax=8] {tmp-001.png};
5757
\path [draw=black, line width=0.32pt]
58-
(axis cs:-0.05,0.5)
59-
--(axis cs:0,0)
60-
--(axis cs:1,0)
61-
--(axis cs:1.05,0.5)
62-
--(axis cs:1.05,0.5)
58+
(axis cs:0.65,4.5)
6359
--(axis cs:1,1)
64-
--(axis cs:0,1)
65-
--(axis cs:-0.05,0.5)
60+
--(axis cs:8,1)
61+
--(axis cs:8.35,4.5)
62+
--(axis cs:8.35,4.5)
63+
--(axis cs:8,8)
64+
--(axis cs:1,8)
65+
--(axis cs:0.65,4.5)
6666
--cycle;
6767

6868
\nextgroupplot[
6969
tick align=outside,
7070
tick pos=left,
7171
x grid style={white!69.019608!black},
7272
xlabel={Custom extension lengths, some other units},
73-
xmin=-0.25, xmax=1.25,
73+
xmin=-1.5, xmax=1.5,
7474
xtick style={color=black},
75-
xtick={0,0.25,0.5,0.75,1},
76-
xticklabels={−1.0,−0.5,0.0,0.5,1.0},
77-
ymin=0, ymax=1
75+
ymin=-1, ymax=1
7876
]
7977
\path [draw=white, fill=white, line width=0.004pt]
80-
(axis cs:-0.25,0.5)
81-
--(axis cs:0,0)
82-
--(axis cs:1,0)
83-
--(axis cs:1.25,0.5)
84-
--(axis cs:1.25,0.5)
78+
(axis cs:-1.5,0)
79+
--(axis cs:-1,-1)
80+
--(axis cs:1,-1)
81+
--(axis cs:1.5,0)
82+
--(axis cs:1.5,0)
8583
--(axis cs:1,1)
86-
--(axis cs:0,1)
87-
--(axis cs:-0.25,0.5)
84+
--(axis cs:-1,1)
85+
--(axis cs:-1.5,0)
8886
--cycle;
89-
\addplot graphics [includegraphics cmd=\pgfimage,xmin=-0.25, xmax=1.25, ymin=0, ymax=1] {tmp-002.png};
87+
\addplot graphics [includegraphics cmd=\pgfimage,xmin=-1.5, xmax=1.5, ymin=-1, ymax=1] {tmp-002.png};
9088
\path [draw=black, line width=0.32pt]
91-
(axis cs:-0.25,0.5)
92-
--(axis cs:0,0)
93-
--(axis cs:1,0)
94-
--(axis cs:1.25,0.5)
95-
--(axis cs:1.25,0.5)
89+
(axis cs:-1.5,0)
90+
--(axis cs:-1,-1)
91+
--(axis cs:1,-1)
92+
--(axis cs:1.5,0)
93+
--(axis cs:1.5,0)
9694
--(axis cs:1,1)
97-
--(axis cs:0,1)
98-
--(axis cs:-0.25,0.5)
95+
--(axis cs:-1,1)
96+
--(axis cs:-1.5,0)
9997
--cycle;
10098
\end{groupplot}
10199

test/test_legend_line_scatter_reference.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
tick align=outside,
99
tick pos=left,
1010
x grid style={white!69.019608!black},
11-
xmin=-0.22927419, xmax=4.2292742,
11+
xmin=-0.2, xmax=4.2,
1212
xtick style={color=black},
1313
y grid style={white!69.019608!black},
14-
ymin=-0.23928571, ymax=4.2392857,
14+
ymin=-0.2, ymax=4.2,
1515
ytick style={color=black}
1616
]
1717
\addplot [only marks, mark=*, draw=color0, fill=color0, colormap/viridis]

test/test_scatter_colormap_reference.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
tick align=outside,
55
tick pos=left,
66
x grid style={white!69.019608!black},
7-
xmin=-2.6372526, xmax=1.8614963,
7+
xmin=-2.630585, xmax=1.8553423,
88
xtick style={color=black},
99
y grid style={white!69.019608!black},
10-
ymin=-0.83585322, ymax=2.3593314,
10+
ymin=-0.82312696, ymax=2.3501709,
1111
ytick style={color=black}
1212
]
1313
\addplot [only marks, scatter, scatter src=explicit, colormap/viridis, visualization depends on={\thisrow{sizedata} \as\perpointmarksize}, scatter/@pre marker code/.append style={/tikz/mark size=\perpointmarksize}]

test/test_scatter_reference.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
tick pos=left,
1010
x grid style={white!79.607843!black},
1111
xmajorgrids,
12-
xmin=-5.0066532, xmax=105.00665,
12+
xmin=-5, xmax=105,
1313
xtick style={color=black},
1414
y grid style={white!79.607843!black},
1515
ymajorgrids,
16-
ymin=0.16291984, ymax=112.82609,
16+
ymin=0.17184841, ymax=112.81716,
1717
ytick style={color=black}
1818
]
1919
\addplot [only marks, mark=*, draw=color0, fill=color0, colormap/viridis]

tikzplotlib/_axes.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,18 @@ def _ticks(self, data, obj):
208208
)
209209
self.axis_options.extend(
210210
_get_ticks(
211-
data, "minor x", obj.get_xticks("minor"), obj.get_xticklabels("minor")
211+
data,
212+
"minor x",
213+
obj.get_xticks(minor=True),
214+
obj.get_xticklabels(minor=True),
212215
)
213216
)
214217
self.axis_options.extend(
215218
_get_ticks(
216-
data, "minor y", obj.get_yticks("minor"), obj.get_yticklabels("minor")
219+
data,
220+
"minor y",
221+
obj.get_yticks(minor=True),
222+
obj.get_yticklabels(minor=True),
217223
)
218224
)
219225

@@ -323,7 +329,7 @@ def _colorbar(self, colorbar, data):
323329
self.axis_options.append("colorbar horizontal")
324330

325331
colorbar_ticks = colorbar.ax.get_xticks()
326-
colorbar_ticks_minor = colorbar.ax.get_xticks("minor")
332+
colorbar_ticks_minor = colorbar.ax.get_xticks(minor=True)
327333
axis_limits = colorbar.ax.get_xlim()
328334

329335
# In matplotlib, the colorbar color limits are determined by get_clim(), and
@@ -339,7 +345,7 @@ def _colorbar(self, colorbar, data):
339345
# Getting the labels via get_* might not actually be suitable:
340346
# they might not reflect the current state.
341347
colorbar_ticklabels = colorbar.ax.get_xticklabels()
342-
colorbar_ticklabels_minor = colorbar.ax.get_xticklabels("minor")
348+
colorbar_ticklabels_minor = colorbar.ax.get_xticklabels(minor=True)
343349

344350
colorbar_styles.extend(
345351
_get_ticks(data, "x", colorbar_ticks, colorbar_ticklabels)
@@ -355,7 +361,7 @@ def _colorbar(self, colorbar, data):
355361

356362
self.axis_options.append("colorbar")
357363
colorbar_ticks = colorbar.ax.get_yticks()
358-
colorbar_ticks_minor = colorbar.ax.get_yticks("minor")
364+
colorbar_ticks_minor = colorbar.ax.get_yticks(minor=True)
359365
axis_limits = colorbar.ax.get_ylim()
360366

361367
# In matplotlib, the colorbar color limits are determined by get_clim(), and
@@ -373,7 +379,7 @@ def _colorbar(self, colorbar, data):
373379
# they might not reflect the current state.
374380
colorbar_ticklabels = colorbar.ax.get_yticklabels()
375381
colorbar_ylabel = colorbar.ax.get_ylabel()
376-
colorbar_ticklabels_minor = colorbar.ax.get_yticklabels("minor")
382+
colorbar_ticklabels_minor = colorbar.ax.get_yticklabels(minor=True)
377383
colorbar_styles.extend(
378384
_get_ticks(data, "y", colorbar_ticks, colorbar_ticklabels)
379385
)

0 commit comments

Comments
 (0)