{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Set default y-axis tick labels on the right\n\nWe can use :rc:`ytick.labelright`, :rc:`ytick.right`, :rc:`ytick.labelleft`,\nand :rc:`ytick.left` to control where on the axes ticks and their labels\nappear. These properties can also be set in ``.matplotlib/matplotlibrc``.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nplt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True\nplt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False\n\nx = np.arange(10)\n\nfig, (ax0, ax1) = plt.subplots(2, 1, sharex=True, figsize=(6, 6))\n\nax0.plot(x)\nax0.yaxis.tick_left()\n\n# use default parameter in rcParams, not calling tick_right()\nax1.plot(x)\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 }