{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Node and Edge Artist Customisation\n\n## Node artists\n\nThe shape, size, and colour of node representations can be controlled via the following parameters:\n\n- :code:`node_shape` : node shape; one of 'so^>v<dph8'\n- :code:`node_size` : node radius\n- :code:`node_edge_width` : line width of node marker border\n- :code:`node_color` : node face colour\n- :code:`node_edge_color` : node edge colour\n- :code:`node_alpha` : node transparency\n- :code:`node_zorder` : node z-order; artists with higher z-order occlude artists with lower z-order\n\n## Edge artists\n\nThe shape, size, and colour of edge representations can be controlled via the following parameters:\n\n- :code:`edge_width` : edge width\n- :code:`edge_color` : edge face colour\n- :code:`edge_alpha` : edge transparency\n- :code:`edge_zorder` : node zorder; artists with higher z-order occlude artists with lower z-order\n- :code:`arrows` : boolean flag that turn the drawing of arrow heads on or off\n\nAll node and edge artist properties can be specified in three ways:\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "1. Using a single scalar or string that will be applied to all artists.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nfrom netgraph import Graph\n\nedges = [(0, 1), (1, 1)]\nGraph(edges, node_color='red', node_size=4.)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "2. Using a dictionary mapping individual nodes or individual edges to a property:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\nfrom netgraph import Graph\n\nGraph([(0, 1), (1, 2), (2, 0)],\n      edge_color={(0, 1) : 'g', (1, 2) : 'lightblue', (2, 0) : np.array([1, 0, 0])},\n      node_size={0 : 20, 1 : 4.2, 2 : np.pi},\n)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "3. By directly manipulating the node and edge artists.\n\nNode and edge artists are derived from the :code:`matplotlib.patches.PathPatch` class,\nsuch that any of its methods can be used to modify node and edge artists properties.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt; plt.ion()\nfrom netgraph import Graph\n\nfig, ax = plt.subplots()\ng = Graph([(0, 1), (1, 2), (2, 0)], ax=ax)\nplt.show()\n\n# make some changes\ng.node_artists[0].set_alpha(0.2)\ng.edge_artists[(1, 2)].set_facecolor('red')\n\n# force redraw to display changes\nfig.canvas.draw()"
      ]
    }
  ],
  "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.6.8"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}