{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Axes with a fixed physical size\n\nNote that this can be accomplished with the main library for\nAxes on Figures that do not change size: `fixed_size_axes`\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfrom mpl_toolkits.axes_grid1 import Divider, Size" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig = plt.figure(figsize=(6, 6))\n\n# The first items are for padding and the second items are for the Axes.\n# sizes are in inch.\nh = [Size.Fixed(1.0), Size.Fixed(4.5)]\nv = [Size.Fixed(0.7), Size.Fixed(5.)]\n\ndivider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False)\n# The width and height of the rectangle are ignored.\n\nax = fig.add_axes(divider.get_position(),\n axes_locator=divider.new_locator(nx=1, ny=1))\n\nax.plot([1, 2, 3])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig = plt.figure(figsize=(6, 6))\n\n# The first & third items are for padding and the second items are for the\n# Axes. Sizes are in inches.\nh = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)]\nv = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)]\n\ndivider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False)\n# The width and height of the rectangle are ignored.\n\nax = fig.add_axes(divider.get_position(),\n axes_locator=divider.new_locator(nx=1, ny=1))\n\nax.plot([1, 2, 3])\n\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }