Skip to content

Commit 19aba5e

Browse files
authored
Merge pull request #280 from nschloe/rotated-ellipse
respect ellipse rotation
2 parents b1cbcd3 + afb0006 commit 19aba5e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

matplotlib2tikz/patch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def _draw_ellipse(data, obj, draw_options):
124124
return _draw_circle(data, obj, draw_options)
125125
x, y = obj.center
126126
ff = data["float format"]
127+
128+
if obj.angle != 0:
129+
fmt = "rotate around={{" + ff + ":(axis cs:" + ff + "," + ff + ")}}"
130+
draw_options.append(fmt.format(obj.angle, x, y))
131+
127132
cont = (
128133
"\\draw[{}] (axis cs:"
129134
+ ff

test/test_patches.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ def plot():
6767
def test():
6868
assert_equality(plot, __file__[:-3] + "_reference.tex")
6969
return
70+
71+
72+
if __name__ == "__main__":
73+
import helpers
74+
75+
helpers.compare_mpl_latex(plot)
76+
# helpers.print_tree(plot())

test/test_patches_reference.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
--(axis cs:0.623952951792111,0.115618395079296)
195195
--cycle;
196196

197-
\draw[fill=color0,draw opacity=0,fill opacity=0.4] (axis cs:1,0.5) ellipse (0.5 and 0.25);
197+
\draw[fill=color0,draw opacity=0,fill opacity=0.4,rotate around={45:(axis cs:1,0.5)}] (axis cs:1,0.5) ellipse (0.5 and 0.25);
198198
\draw[draw=red,fill=red,opacity=0.4] (axis cs:0,1) circle (0.5);
199199
\end{axis}
200200

0 commit comments

Comments
 (0)