{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plot - Scatter\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from gemseo.api import configure_logger\nfrom gemseo.core.dataset import Dataset\nfrom gemseo.post.dataset.scatter import Scatter\nfrom matplotlib import pyplot as plt\nfrom numpy import linspace\nfrom numpy import pi\nfrom numpy import sin\n\nconfigure_logger()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Build a dataset\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "inputs = linspace(0, 1, 20)[:, None]\noutputs = sin(2 * pi * inputs)\ncolor = [\"b\" if abs(output) > 0.5 else \"r\" for output in outputs]\n\ndataset = Dataset()\ndataset.add_variable(\"x\", inputs, \"inputs\")\ndataset.add_variable(\"y\", outputs, \"outputs\", cache_as_input=False)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plot y vs x\nWe can use the :class:`.Scatter` plot\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plot = Scatter(dataset, \"x\", \"y\")\nplot.color = color\nplot.execute(show=False, save=False)\n# Workaround for HTML rendering, instead of ``show=True``\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.9.13"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}