Skip to content

Commit 30b6e10

Browse files
committed
update some reference files
1 parent d2c3b6f commit 30b6e10

8 files changed

+92
-23
lines changed

test/test_barchart_legend_reference.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
\begin{axis}[
44
legend cell align={left},
5-
legend style={fill opacity=0.8, draw opacity=1, text opacity=1, draw=white!80!black},
5+
legend style={
6+
fill opacity=0.8,
7+
draw opacity=1,
8+
text opacity=1,
9+
at={(0.5,0.91)},
10+
anchor=north,
11+
draw=white!80!black
12+
},
613
tick align=outside,
714
tick pos=left,
815
x grid style={white!69.019608!black},

test/test_dual_axis_reference.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
y grid style={white!69.019608!black},
4949
ymin=-100, ymax=2100,
5050
ytick pos=right,
51-
ytick style={color=black}
51+
ytick style={color=black},
52+
yticklabel style={anchor=west}
5253
]
5354
\addplot [semithick, color0]
5455
table {%

test/test_hatch_reference.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@
4545

4646
\nextgroupplot[
4747
legend cell align={left},
48-
legend style={fill opacity=0.8, draw opacity=1, text opacity=1, draw=white!80!black},
48+
legend style={
49+
fill opacity=0.8,
50+
draw opacity=1,
51+
text opacity=1,
52+
at={(0.91,0.5)},
53+
anchor=east,
54+
draw=white!80!black
55+
},
4956
tick align=outside,
5057
tick pos=left,
5158
x grid style={white!69.019608!black},

test/test_horizontal_alignment.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
from helpers import assert_equality
5+
6+
7+
def plot():
8+
labels = ["lab1", "label 2", "another super label"]
9+
n = len(labels)
10+
x = np.arange(n)
11+
y = 1 / (x + 1)
12+
13+
ax = plt.gca()
14+
ax.bar(x, y, 0.5)
15+
16+
ax.set_xticks(x)
17+
ax.set_xticklabels(labels)
18+
plt.xticks(rotation=45, ha="right")
19+
20+
21+
def test():
22+
assert_equality(plot, "test_horizontal_alignment_reference.tex")
23+
24+
25+
if __name__ == "__main__":
26+
# import helpers
27+
# helpers.compare_mpl_tex(plot)
28+
plot()
29+
plt.show()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
\begin{tikzpicture}
2+
3+
\definecolor{color0}{rgb}{0.12156863,0.46666667,0.70588235}
4+
5+
\begin{axis}[
6+
tick align=outside,
7+
tick pos=left,
8+
x grid style={white!69.019608!black},
9+
xmin=-0.375, xmax=2.375,
10+
xtick style={color=black},
11+
xtick={0,1,2},
12+
xticklabel style={rotate=45.0,anchor=east},
13+
xticklabels={lab1,label 2,another super label},
14+
y grid style={white!69.019608!black},
15+
ymin=0, ymax=1.05,
16+
ytick style={color=black}
17+
]
18+
\draw[draw=none,fill=color0] (axis cs:-0.25,0) rectangle (axis cs:0.25,1);
19+
\draw[draw=none,fill=color0] (axis cs:0.75,0) rectangle (axis cs:1.25,0.5);
20+
\draw[draw=none,fill=color0] (axis cs:1.75,0) rectangle (axis cs:2.25,0.33333333);
21+
\end{axis}
22+
23+
\end{tikzpicture}

test/test_legend_best_location_reference.tex

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
fill opacity=0.8,
4848
draw opacity=1,
4949
text opacity=1,
50-
at={(0.03,0.97)},
51-
anchor=north west,
50+
at={(0.5,0.91)},
51+
anchor=north,
5252
draw=white!80!black
5353
},
5454
scaled x ticks=manual:{}{\pgfmathparse{#1}},
@@ -135,8 +135,8 @@
135135
fill opacity=0.8,
136136
draw opacity=1,
137137
text opacity=1,
138-
at={(0.03,0.03)},
139-
anchor=south west,
138+
at={(0.97,0.03)},
139+
anchor=south east,
140140
draw=white!80!black
141141
},
142142
scaled x ticks=manual:{}{\pgfmathparse{#1}},
@@ -239,8 +239,8 @@
239239
fill opacity=0.8,
240240
draw opacity=1,
241241
text opacity=1,
242-
at={(0.09,0.5)},
243-
anchor=west,
242+
at={(0.5,0.5)},
243+
anchor=center,
244244
draw=white!80!black
245245
},
246246
scaled x ticks=manual:{}{\pgfmathparse{#1}},
@@ -321,8 +321,8 @@
321321
fill opacity=0.8,
322322
draw opacity=1,
323323
text opacity=1,
324-
at={(0.5,0.09)},
325-
anchor=south,
324+
at={(0.97,0.03)},
325+
anchor=south east,
326326
draw=white!80!black
327327
},
328328
tick align=outside,
@@ -357,14 +357,7 @@
357357

358358
\nextgroupplot[
359359
legend cell align={left},
360-
legend style={
361-
fill opacity=0.8,
362-
draw opacity=1,
363-
text opacity=1,
364-
at={(0.5,0.91)},
365-
anchor=north,
366-
draw=white!80!black
367-
},
360+
legend style={fill opacity=0.8, draw opacity=1, text opacity=1, draw=white!80!black},
368361
scaled y ticks=manual:{}{\pgfmathparse{#1}},
369362
tick align=outside,
370363
tick pos=left,
@@ -398,7 +391,14 @@
398391
\addlegendentry{UC}
399392

400393
\nextgroupplot[
401-
legend style={fill opacity=0.8, draw opacity=1, text opacity=1, draw=white!80!black},
394+
legend style={
395+
fill opacity=0.8,
396+
draw opacity=1,
397+
text opacity=1,
398+
at={(0.91,0.5)},
399+
anchor=east,
400+
draw=white!80!black
401+
},
402402
scaled y ticks=manual:{}{\pgfmathparse{#1}},
403403
tick align=outside,
404404
tick pos=left,

tikzplotlib/_axes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ def _get_label_rotation_and_horizontal_alignment(self, obj, data, x_or_y):
479479
anchor = {"right": "east", "left": "west", "center": "center"}[
480480
tick_labels_horizontal_alignment[0]
481481
]
482-
if anchor != "center":
482+
if not (x_or_y == "x" and anchor == "center") and not (
483+
x_or_y == "y" and anchor == "east"
484+
):
483485
values.append(f"anchor={anchor}")
484486

485487
if values:

tikzplotlib/_save.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def get_tikz_code(
227227
code += "[\n" + ",\n".join(extra_tikzpicture_parameters) + "\n]"
228228
code += "\n"
229229
if extra_lines_start:
230-
code += "\n".join(extra_lines_start)
231-
code += "\n\n"
230+
code += "\n".join(extra_lines_start) + "\n"
231+
code += "\n"
232232

233233
coldefs = _get_color_definitions(data)
234234
if coldefs:

0 commit comments

Comments
 (0)