Skip to content

Commit aee7a4f

Browse files
authored
Merge pull request #326 from lukasmu/inverse-axis-fix
Inverse axis fix
2 parents b2efc72 + 0a46f8f commit aee7a4f

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
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}

test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pandas
2-
scipy
2+
scipy

tikzplotlib/axes.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Axes:
9-
def __init__(self, data, obj):
9+
def __init__(self, data, obj): # noqa: C901
1010
"""Returns the PGFPlots code for an axis environment.
1111
"""
1212
self.content = []
@@ -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)