|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class Axes: |
9 | | - def __init__(self, data, obj): |
| 9 | + def __init__(self, data, obj): # noqa: C901 |
10 | 10 | """Returns the PGFPlots code for an axis environment. |
11 | 11 | """ |
12 | 12 | self.content = [] |
@@ -59,12 +59,17 @@ def __init__(self, data, obj): |
59 | 59 | ) |
60 | 60 |
|
61 | 61 | # Axes limits. |
62 | | - # Sort the limits so make sure that the smaller of the two is actually *min. |
63 | 62 | 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") |
68 | 73 |
|
69 | 74 | # axes scaling |
70 | 75 | if obj.get_xscale() == "log": |
|
0 commit comments