コード例 #1
0
# Suppose we also want to include a small image of a sun in the upper
# right corner.  If the image is saved in .png or .pdf format, it can
# be easily added to the figure.
#
# There are a few different options for specifying the position of the
# image.  As with an axis, we could specify both the position of the
# bottom left corner.  However, unless the image is square, this could
# be a pain in the butt to calculate the exact dimensions to avoid
# stretching the image.  Instead, we can specify either the width or
# the height of the image and the position to have the dimensions be
# determined automatically.
c.add_image("sun.png",
            pos=Point(4.95, 2.95, "inches"),
            width=Vector(.3, 0, "inches"),
            horizontalalignment="right",
            verticalalignment="top")

# Finally, since we have several figures, we would like to number them
# "a", "b", "c" and "d".  There is a convenience function to do this
# automatically in a standardized format - simply list the desired
# letter and axis name as a tuple.  An option third entry of the tuple
# can specify an offset if desired.
c.add_figure_labels([("a", "scatter"), ("b", "point7"), ("c", "point8"),
                     ("d", "point5")])

# Once we are done, we can save this as a low-resolution png, a
# high-resolution png, and a pdf.
c.save("test.pdf")
c.save("test.png")
c.save("test-hires.png", dpi=450)