Skip to content

Commit 7eedfa5

Browse files
author
Lukas Müller
committed
Export axis direction correctly (fixes #301 and fixes #302)
1 parent 5271531 commit 7eedfa5

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

test/test_fancy_colorbar_reference.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
x grid style={white!69.01960784313725!black},
1212
xmin=-0.5, xmax=2.5,
1313
xtick style={color=black},
14+
y dir=reverse,
1415
y grid style={white!69.01960784313725!black},
1516
ymin=-0.5, ymax=2.5,
1617
ytick style={color=black}

test/test_noise2_reference.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
x grid style={white!69.01960784313725!black},
1313
xmin=-0.5, xmax=249.5,
1414
xtick style={color=black},
15+
y dir=reverse,
1516
y grid style={white!69.01960784313725!black},
1617
ymin=-0.5, ymax=249.5,
1718
ytick style={color=black}

test/test_noise_reference.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
x grid style={white!69.01960784313725!black},
1313
xmin=-0.5, xmax=249.5,
1414
xtick style={color=black},
15+
y dir=reverse,
1516
y grid style={white!69.01960784313725!black},
1617
ymin=-0.5, ymax=249.5,
1718
ytick style={color=black}

tikzplotlib/axes.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ def __init__(self, data, obj):
5959
)
6060

6161
# Axes limits.
62-
# Sort the limits so make sure that the smaller of the two is actually *min.
6362
ff = data["float format"]
64-
xlim = sorted(list(obj.get_xlim()))
65-
self.axis_options.append(("xmin=" + ff + ", xmax=" + ff).format(*xlim))
66-
ylim = sorted(list(obj.get_ylim()))
67-
self.axis_options.append(("ymin=" + ff + ", ymax=" + ff).format(*ylim))
63+
xlim = list(obj.get_xlim())
64+
ylim = list(obj.get_ylim())
65+
# Sort the limits so make sure that the smaller of the two is actually *min.
66+
self.axis_options.append(("xmin=" + ff + ", xmax=" + ff).format(*sorted(xlim)))
67+
self.axis_options.append(("ymin=" + ff + ", ymax=" + ff).format(*sorted(ylim)))
68+
# When the axis is inverted add additional option
69+
if (xlim != sorted(xlim)):
70+
self.axis_options.append("x dir=reverse")
71+
if (ylim != sorted(ylim)):
72+
self.axis_options.append("y dir=reverse")
6873

6974
# axes scaling
7075
if obj.get_xscale() == "log":

0 commit comments

Comments
 (0)