{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Fig Axes Customize Simple\n\nCustomize the background, labels and ticks of a simple plot.\n\n.. redirect-from:: /gallery/pyplots/fig_axes_customize_simple\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`.pyplot.figure` creates a `matplotlib.figure.Figure` instance.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig = plt.figure()\nrect = fig.patch # a rectangle instance\nrect.set_facecolor('lightgoldenrodyellow')\n\nax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])\nrect = ax1.patch\nrect.set_facecolor('lightslategray')\n\nax1.tick_params(axis='x', labelcolor='tab:red', labelrotation=45, labelsize=16)\nax1.tick_params(axis='y', color='tab:green', size=25, width=3)\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. admonition:: References\n\n The use of the following functions, methods, classes and modules is shown\n in this example:\n\n - `matplotlib.axis.Axis.get_ticklabels`\n - `matplotlib.axis.Axis.get_ticklines`\n - `matplotlib.text.Text.set_rotation`\n - `matplotlib.text.Text.set_fontsize`\n - `matplotlib.text.Text.set_color`\n - `matplotlib.lines.Line2D`\n - `matplotlib.lines.Line2D.set_markeredgecolor`\n - `matplotlib.lines.Line2D.set_markersize`\n - `matplotlib.lines.Line2D.set_markeredgewidth`\n - `matplotlib.patches.Patch.set_facecolor`\n\n" ] } ], "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 }