{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Dashed line style configuration\n\nThe dashing of a line is controlled via a dash sequence. It can be modified\nusing `.Line2D.set_dashes`.\n\nThe dash sequence is a series of on/off lengths in points, e.g.\n``[3, 1]`` would be 3pt long lines separated by 1pt spaces.\n\nSome functions like `.Axes.plot` support passing Line properties as keyword\narguments. In such a case, you can already set the dashing when creating the\nline.\n\n*Note*: The dash style can also be configured via a\n`property_cycle <color_cycle>`\nby passing a list of dash sequences using the keyword *dashes* to the\ncycler. This is not shown within this example.\n\nOther attributes of the dash may also be set either with the relevant method\n(`~.Line2D.set_dash_capstyle`, `~.Line2D.set_dash_joinstyle`,\n`~.Line2D.set_gapcolor`) or by passing the property through a plotting\nfunction.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.linspace(0, 10, 500)\ny = np.sin(x)\n\nplt.rc('lines', linewidth=2.5)\nfig, ax = plt.subplots()\n\n# Using set_dashes() and set_capstyle() to modify dashing of an existing line.\nline1, = ax.plot(x, y, label='Using set_dashes() and set_dash_capstyle()')\nline1.set_dashes([2, 2, 10, 2])  # 2pt line, 2pt break, 10pt line, 2pt break.\nline1.set_dash_capstyle('round')\n\n# Using plot(..., dashes=...) to set the dashing when creating a line.\nline2, = ax.plot(x, y - 0.2, dashes=[6, 2], label='Using the dashes parameter')\n\n# Using plot(..., dashes=..., gapcolor=...) to set the dashing and\n# alternating color when creating a line.\nline3, = ax.plot(x, y - 0.4, dashes=[4, 4], gapcolor='tab:pink',\n                 label='Using the dashes and gapcolor parameters')\n\nax.legend(handlelength=4)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n\n   styling: linestyle\n   plot-type: line\n   level: beginner\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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}