piccolbo/altair_recipes

View on GitHub
docs/test_lineplot.html

Summary

Maintainability
Test Coverage

<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">altair_recipes</span> <span class="kn">as</span> <span class="nn">ar</span>
<span class="kn">from</span> <span class="nn">altair_recipes.common</span> <span class="kn">import</span> <span class="n">viz_reg_test</span>
<span class="kn">from</span> <span class="nn">altair_recipes.display_pweave</span> <span class="kn">import</span> <span class="n">show_test</span>
<span class="kn">from</span> <span class="nn">vega_datasets</span> <span class="kn">import</span> <span class="n">data</span>
</pre></div>

<h2>Lineplot</h2>




<div class="highlight"><pre><span></span><span class="nd">@viz_reg_test</span>
<span class="k">def</span> <span class="nf">test_lineplot</span><span class="p">():</span>
    <span class="k">return</span> <span class="n">ar</span><span class="o">.</span><span class="n">lineplot</span><span class="p">(</span>
        <span class="n">data</span><span class="o">.</span><span class="n">iowa_electricity</span><span class="p">(),</span> <span class="n">x</span><span class="o">=</span><span class="s2">&quot;year&quot;</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="s2">&quot;net_generation&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;source&quot;</span>
    <span class="p">)</span>


<span class="n">show_test</span><span class="p">(</span><span class="n">test_lineplot</span><span class="p">)</span>
</pre></div>


<script src="https://cdn.jsdelivr.net/npm/vega@3"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
 <div id="Af57c82d110aab0161cfe872e58689d6106cd6692a341de3860f04807d221665f"></div>
  <script type="text/javascript">
    var spec = {
  "$schema": "https://vega.github.io/schema/vega-lite/v4.0.0.json",
  "config": {
    "view": {
      "continuousHeight": 300,
      "continuousWidth": 400
    }
  },
  "data": {
    "name": "data-bb61008ba0c766c5601afa5323d12ad4"
  },
  "datasets": {
    "data-bb61008ba0c766c5601afa5323d12ad4": [
      {
        "net_generation": 35361,
        "source": "Fossil Fuels",
        "year": "2001-01-01T00:00:00"
      },
      {
        "net_generation": 35991,
        "source": "Fossil Fuels",
        "year": "2002-01-01T00:00:00"
      },
      {
        "net_generation": 36234,
        "source": "Fossil Fuels",
        "year": "2003-01-01T00:00:00"
      },
      {
        "net_generation": 36205,
        "source": "Fossil Fuels",
        "year": "2004-01-01T00:00:00"
      },
      {
        "net_generation": 36883,
        "source": "Fossil Fuels",
        "year": "2005-01-01T00:00:00"
      },
      {
        "net_generation": 37014,
        "source": "Fossil Fuels",
        "year": "2006-01-01T00:00:00"
      },
      {
        "net_generation": 41389,
        "source": "Fossil Fuels",
        "year": "2007-01-01T00:00:00"
      },
      {
        "net_generation": 42734,
        "source": "Fossil Fuels",
        "year": "2008-01-01T00:00:00"
      },
      {
        "net_generation": 38620,
        "source": "Fossil Fuels",
        "year": "2009-01-01T00:00:00"
      },
      {
        "net_generation": 42750,
        "source": "Fossil Fuels",
        "year": "2010-01-01T00:00:00"
      },
      {
        "net_generation": 39361,
        "source": "Fossil Fuels",
        "year": "2011-01-01T00:00:00"
      },
      {
        "net_generation": 37379,
        "source": "Fossil Fuels",
        "year": "2012-01-01T00:00:00"
      },
      {
        "net_generation": 34873,
        "source": "Fossil Fuels",
        "year": "2013-01-01T00:00:00"
      },
      {
        "net_generation": 35250,
        "source": "Fossil Fuels",
        "year": "2014-01-01T00:00:00"
      },
      {
        "net_generation": 32319,
        "source": "Fossil Fuels",
        "year": "2015-01-01T00:00:00"
      },
      {
        "net_generation": 28437,
        "source": "Fossil Fuels",
        "year": "2016-01-01T00:00:00"
      },
      {
        "net_generation": 29329,
        "source": "Fossil Fuels",
        "year": "2017-01-01T00:00:00"
      },
      {
        "net_generation": 3853,
        "source": "Nuclear Energy",
        "year": "2001-01-01T00:00:00"
      },
      {
        "net_generation": 4574,
        "source": "Nuclear Energy",
        "year": "2002-01-01T00:00:00"
      },
      {
        "net_generation": 3988,
        "source": "Nuclear Energy",
        "year": "2003-01-01T00:00:00"
      },
      {
        "net_generation": 4929,
        "source": "Nuclear Energy",
        "year": "2004-01-01T00:00:00"
      },
      {
        "net_generation": 4538,
        "source": "Nuclear Energy",
        "year": "2005-01-01T00:00:00"
      },
      {
        "net_generation": 5095,
        "source": "Nuclear Energy",
        "year": "2006-01-01T00:00:00"
      },
      {
        "net_generation": 4519,
        "source": "Nuclear Energy",
        "year": "2007-01-01T00:00:00"
      },
      {
        "net_generation": 5282,
        "source": "Nuclear Energy",
        "year": "2008-01-01T00:00:00"
      },
      {
        "net_generation": 4679,
        "source": "Nuclear Energy",
        "year": "2009-01-01T00:00:00"
      },
      {
        "net_generation": 4451,
        "source": "Nuclear Energy",
        "year": "2010-01-01T00:00:00"
      },
      {
        "net_generation": 5215,
        "source": "Nuclear Energy",
        "year": "2011-01-01T00:00:00"
      },
      {
        "net_generation": 4347,
        "source": "Nuclear Energy",
        "year": "2012-01-01T00:00:00"
      },
      {
        "net_generation": 5321,
        "source": "Nuclear Energy",
        "year": "2013-01-01T00:00:00"
      },
      {
        "net_generation": 4152,
        "source": "Nuclear Energy",
        "year": "2014-01-01T00:00:00"
      },
      {
        "net_generation": 5243,
        "source": "Nuclear Energy",
        "year": "2015-01-01T00:00:00"
      },
      {
        "net_generation": 4703,
        "source": "Nuclear Energy",
        "year": "2016-01-01T00:00:00"
      },
      {
        "net_generation": 5214,
        "source": "Nuclear Energy",
        "year": "2017-01-01T00:00:00"
      },
      {
        "net_generation": 1437,
        "source": "Renewables",
        "year": "2001-01-01T00:00:00"
      },
      {
        "net_generation": 1963,
        "source": "Renewables",
        "year": "2002-01-01T00:00:00"
      },
      {
        "net_generation": 1885,
        "source": "Renewables",
        "year": "2003-01-01T00:00:00"
      },
      {
        "net_generation": 2102,
        "source": "Renewables",
        "year": "2004-01-01T00:00:00"
      },
      {
        "net_generation": 2724,
        "source": "Renewables",
        "year": "2005-01-01T00:00:00"
      },
      {
        "net_generation": 3364,
        "source": "Renewables",
        "year": "2006-01-01T00:00:00"
      },
      {
        "net_generation": 3870,
        "source": "Renewables",
        "year": "2007-01-01T00:00:00"
      },
      {
        "net_generation": 5070,
        "source": "Renewables",
        "year": "2008-01-01T00:00:00"
      },
      {
        "net_generation": 8560,
        "source": "Renewables",
        "year": "2009-01-01T00:00:00"
      },
      {
        "net_generation": 10308,
        "source": "Renewables",
        "year": "2010-01-01T00:00:00"
      },
      {
        "net_generation": 11795,
        "source": "Renewables",
        "year": "2011-01-01T00:00:00"
      },
      {
        "net_generation": 14949,
        "source": "Renewables",
        "year": "2012-01-01T00:00:00"
      },
      {
        "net_generation": 16476,
        "source": "Renewables",
        "year": "2013-01-01T00:00:00"
      },
      {
        "net_generation": 17452,
        "source": "Renewables",
        "year": "2014-01-01T00:00:00"
      },
      {
        "net_generation": 19091,
        "source": "Renewables",
        "year": "2015-01-01T00:00:00"
      },
      {
        "net_generation": 21241,
        "source": "Renewables",
        "year": "2016-01-01T00:00:00"
      },
      {
        "net_generation": 21933,
        "source": "Renewables",
        "year": "2017-01-01T00:00:00"
      }
    ]
  },
  "encoding": {
    "color": {
      "field": "source",
      "type": "nominal"
    },
    "x": {
      "field": "year",
      "type": "temporal"
    },
    "y": {
      "field": "net_generation",
      "type": "quantitative"
    }
  },
  "height": 600,
  "mark": "line",
  "width": 800
};
    var opt = {"renderer": "canvas", "actions": false};
    vegaEmbed("#Af57c82d110aab0161cfe872e58689d6106cd6692a341de3860f04807d221665f", spec, opt);
  </script>