1.784 3.282, 1.347 3.282))''') # 1 ax = fig.add_subplot(121) patch1a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) skewR = affinity.skew(R, xs=20, origin=(1, 1)) patch1b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch1a) ax.add_patch(patch1b) add_origin(ax, R, (1, 1)) ax.set_title("a) xs=20, origin(1, 1)") set_limits(ax, 0, 5, 0, 4) # 2 ax = fig.add_subplot(122) patch2a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) skewR = affinity.skew(R, ys=30) patch2b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2)
patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) triangle_a = affinity.scale(triangle, xfact=1.5, yfact=-1) patch_a = PolygonPatch(triangle_a, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch) ax.add_patch(patch_a) add_origin(ax, triangle, 'center') ax.set_title("a) xfact=1.5, yfact=-1") set_limits(ax, 0, 5, 0, 4) # 2 ax = fig.add_subplot(122) patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) triangle_b = affinity.scale(triangle, xfact=2, origin=(1, 1)) patch_b = PolygonPatch(triangle_b,
(1.347 3.282, 1.347 2.371, 1.784 2.371, 1.902 2.378, 2.004 2.4, 2.091 2.436, 2.163 2.487, 2.219 2.552, 2.259 2.63, 2.283 2.722, 2.291 2.828, 2.283 2.933, 2.259 3.025, 2.219 3.103, 2.163 3.167, 2.091 3.217, 2.004 3.253, 1.902 3.275, 1.784 3.282, 1.347 3.282))""" ) # 1 ax = fig.add_subplot(121) patch1a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) skewR = affinity.skew(R, xs=20, origin=(1, 1)) patch1b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch1a) ax.add_patch(patch1b) add_origin(ax, R, (1, 1)) ax.set_title("a) xs=20, origin(1, 1)") set_limits(ax, 0, 5, 0, 4) # 2 ax = fig.add_subplot(122) patch2a = PolygonPatch(R, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) skewR = affinity.skew(R, ys=30) patch2b = PolygonPatch(skewR, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch2a) ax.add_patch(patch2b) add_origin(ax, R, "center")
from matplotlib import pyplot from shapely.geometry import LineString from shapely import affinity from figures import SIZE, BLUE, GRAY, set_limits, plot_line, add_origin fig = pyplot.figure(1, figsize=SIZE, dpi=90) line = LineString([(1, 3), (1, 1), (4, 1)]) # 1 ax = fig.add_subplot(121) plot_line(ax, line, GRAY) plot_line(ax, affinity.rotate(line, 90, 'center'), BLUE) add_origin(ax, line, 'center') ax.set_title(u"90\N{DEGREE SIGN}, default origin (center)") set_limits(ax, 0, 5, 0, 4) # 2 ax = fig.add_subplot(122) plot_line(ax, line, GRAY) plot_line(ax, affinity.rotate(line, 90, 'centroid'), BLUE) add_origin(ax, line, 'centroid') ax.set_title(u"90\N{DEGREE SIGN}, origin='centroid'") set_limits(ax, 0, 5, 0, 4)
from figures import SIZE, BLUE, GRAY, set_limits, add_origin fig = pyplot.figure(1, figsize=SIZE, dpi=90) triangle = Polygon([(1, 1), (2, 3), (3, 1)]) # 1 ax = fig.add_subplot(121) patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) triangle_a = affinity.scale(triangle, xfact=1.5, yfact=-1) patch_a = PolygonPatch(triangle_a, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch) ax.add_patch(patch_a) add_origin(ax, triangle, "center") ax.set_title("a) xfact=1.5, yfact=-1") set_limits(ax, 0, 5, 0, 4) # 2 ax = fig.add_subplot(122) patch = PolygonPatch(triangle, facecolor=GRAY, edgecolor=GRAY, alpha=0.5, zorder=1) triangle_b = affinity.scale(triangle, xfact=2, origin=(1, 1)) patch_b = PolygonPatch(triangle_b, facecolor=BLUE, edgecolor=BLUE, alpha=0.5, zorder=2) ax.add_patch(patch) ax.add_patch(patch_b) add_origin(ax, triangle, (1, 1))