{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Weighted Graphs (1)\n\nDefault visualisation for a weighted graph.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom netgraph import Graph\n\nweighted_cube = [\n    (0, 1, -0.1),\n    (1, 2, -0.2),\n    (2, 3, -0.4),\n    (3, 2,  0.0),\n    (3, 0, -0.2),\n    (4, 5,  0.7),\n    (5, 6,  0.9),\n    (6, 5, -0.2),\n    (6, 7,  0.5),\n    (7, 4,  0.1),\n    (0, 4,  0.5),\n    (1, 5, -0.3),\n    (5, 1, -0.4),\n    (2, 6,  0.8),\n    (3, 7,  0.4)\n]\n\ncmap = 'RdGy'\nGraph(weighted_cube, edge_cmap=cmap, edge_width=2., arrows=True)\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "By default, different edge weights are represented by different colors.\nThe default colormap is :code:`'RdGy'` but any diverging matplotlib colormap can be used:\n\n- :code:`'PiYG'`\n- :code:`'PRGn'`\n- :code:`'BrBG'`\n- :code:`'PuOr'`\n- :code:`'RdGy'` (default)\n- :code:`'RdBu'`\n- :code:`'RdYlBu'`\n- :code:`'RdYlGn'`\n- :code:`'Spectral'`\n- :code:`'coolwarm'`\n- :code:`'bwr'`\n- :code:`'seismic'`\n\nIf edge weights are strictly positive, weights are mapped to the\nleft hand side of the color map with :code:`vmin=0` and :code:`vmax=np.max(weights)`.\nIf edge weights are positive and negative, then weights are mapped to colors\nsuch that a weight of zero corresponds to the center of the color map;\nthe boundaries are set to +/- the maximum absolute weight.\n\nCustom diverging colormaps can be created using matploltib's :code:`LinearSegmentedColormap`:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from matplotlib.colors import LinearSegmentedColormap\ncmap = LinearSegmentedColormap.from_list('my_name', ['red', 'white', 'blue'])"
      ]
    }
  ],
  "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
}