Skip to content

Commit 9e1084d

Browse files
committed
add test
1 parent 431c664 commit 9e1084d

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

test/test_scatter_different_colors.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from helpers import assert_equality
2+
3+
4+
def plot():
5+
import numpy as np
6+
from matplotlib import pyplot as plt
7+
8+
fig = plt.figure()
9+
np.random.seed(123)
10+
n = 4
11+
plt.scatter(
12+
np.random.rand(n),
13+
np.random.rand(n),
14+
color=np.array(
15+
[
16+
[1.0, 0.6, 0.0],
17+
[0.0, 1.0, 0.0],
18+
[0.0, 0.0, 1.0],
19+
[0.0, 1.0, 1.0],
20+
]
21+
),
22+
edgecolors=np.array(
23+
[
24+
[0.0, 1.0, 0.0],
25+
[0.0, 0.0, 1.0],
26+
[0.0, 1.0, 1.0],
27+
[1.0, 0.0, 0.0],
28+
]
29+
),
30+
)
31+
return fig
32+
33+
34+
def test():
35+
assert_equality(plot, __file__[:-3] + "_reference.tex")
36+
37+
38+
if __name__ == "__main__":
39+
# import helpers
40+
# helpers.compare_mpl_tex(plot)
41+
# helpers.print_tree(plot())
42+
plot()
43+
import matplotlib.pyplot as plt
44+
45+
# plt.show()
46+
# plt.savefig('out.pgf')
47+
import tikzplotlib
48+
49+
tikzplotlib.save("out.tex", standalone=True)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
\begin{tikzpicture}
2+
3+
\begin{axis}[
4+
tick align=outside,
5+
tick pos=left,
6+
x grid style={white!69.019608!black},
7+
xmin=0.20337057, xmax=0.71995007,
8+
xtick style={color=black},
9+
y grid style={white!69.019608!black},
10+
ymin=0.39522357, ymax=1.0086471,
11+
ytick style={color=black}
12+
]
13+
\addplot [
14+
mark=*,
15+
only marks,
16+
scatter,
17+
scatter/@post marker code/.code={%
18+
\endscope
19+
},
20+
scatter/@pre marker code/.code={%
21+
\expanded{%
22+
\noexpand\definecolor{thispointdrawcolor}{RGB}{\drawcolor}%
23+
\noexpand\definecolor{thispointfillcolor}{RGB}{\fillcolor}%
24+
}%
25+
\scope[draw=thispointdrawcolor, fill=thispointfillcolor]%
26+
},
27+
visualization depends on={value \thisrow{draw} \as \drawcolor},
28+
visualization depends on={value \thisrow{fill} \as \fillcolor}
29+
]
30+
table{%
31+
x y draw fill
32+
0.69646919 0.71946897 0,255,0 255,153,0
33+
0.28613933 0.42310646 0,0,255 0,255,0
34+
0.22685145 0.9807642 0,255,255 0,0,255
35+
0.55131477 0.68482974 255,0,0 0,255,255
36+
};
37+
\end{axis}
38+
39+
\end{tikzpicture}

0 commit comments

Comments
 (0)