Skip to content

Commit

Permalink
remove 'in Numpy' in headers and add append, arange, empty and meshgr…
Browse files Browse the repository at this point in the history
…id to docs
  • Loading branch information
Coding-with-Adam committed Nov 7, 2016
1 parent ae5fd8e commit 3d2992a
Show file tree
Hide file tree
Showing 8 changed files with 2,250 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _layouts/user-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{% if page.language != "r" %}
{% unless page.ignore_header %}
<h1>
{{page.name}} in {% if page.language == "plotly_js" %}plotly.js{% elsif page.language == "ggplot2" %}ggplot2{% elsif page.language == "matlab" %}MATLAB{% elsif page.language == "matplotlib" %}matplotlib{% else %}{{page.language | capitalize}}{% endif %}
{% if page.language == "numpy" %} {% else %}{{page.name}} in {% if page.language == "plotly_js" %}plotly.js{% elsif page.language == "ggplot2" %}ggplot2{% elsif page.language == "matlab" %}MATLAB{% elsif page.language == "matplotlib" %}matplotlib{% else %}{{page.language | capitalize}}{% endif %}{% endif %}
</h1>
<p>{{page.description}} </p>

Expand Down
133 changes: 133 additions & 0 deletions _posts/numpy/append/2015-06-30-Append.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
permalink: numpy/append/
description: How to append values to a NumPy array.
name: Append | plotly
has_thumbnail: true
thumbnail: thumbnail/numpy_array.jpg
layout: user-guide
name: Append
language: numpy
title: Append | plotly
display_as: modify-the-array
has_thumbnail: true
page_type: example_index
order: 1
---
{% raw %}
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="New-to-Plotly?">New to Plotly?<a class="anchor-link" href="#New-to-Plotly?">&#182;</a></h4><p>Plotly's Python library is free and open source! <a href="https://plot.ly/python/getting-started/">Get started</a> by downloading the client and <a href="https://plot.ly/python/getting-started/">reading the primer</a>.
<br>You can set up Plotly to work in <a href="https://plot.ly/python/getting-started/#initialization-for-online-plotting">online</a> or <a href="https://plot.ly/python/getting-started/#initialization-for-offline-plotting">offline</a> mode, or in <a href="https://plot.ly/python/getting-started/#start-plotting-online">jupyter notebooks</a>.
<br>We also have a quick-reference <a href="https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf">cheatsheet</a> (new!) to help you get started!</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Imports">Imports<a class="anchor-link" href="#Imports">&#182;</a></h3><p>This tutorial imports <a href="http://www.numpy.org/">Numpy</a>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
<span class="n">np</span><span class="o">.</span><span class="n">__version__</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area"><div class="prompt output_prompt">Out[1]:</div>


<div class="output_text output_subarea output_execute_result">
<pre>&#39;1.11.2&#39;</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Append-Data">Append Data<a class="anchor-link" href="#Append-Data">&#182;</a></h4><p>Very similar in application to the core Python list method <code>.append()</code>, the <code>np.append()</code> function takes an <code>array</code> and some <code>values</code> in the form of an array and extends the length of the given array and adds the given item at the end.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">import</span> <span class="nn">plotly.plotly</span> <span class="kn">as</span> <span class="nn">py</span>
<span class="kn">import</span> <span class="nn">plotly.graph_objs</span> <span class="kn">as</span> <span class="nn">go</span>
<span class="kn">from</span> <span class="nn">plotly</span> <span class="kn">import</span> <span class="n">tools</span>
<span class="kn">from</span> <span class="nn">plotly.tools</span> <span class="kn">import</span> <span class="n">FigureFactory</span> <span class="k">as</span> <span class="n">FF</span>

<span class="n">array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">])</span>
<span class="n">longer_array</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">array</span><span class="p">,</span> <span class="p">[</span><span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">])</span>

<span class="n">trace1</span> <span class="o">=</span> <span class="n">go</span><span class="o">.</span><span class="n">Scatter</span><span class="p">(</span>
<span class="n">x</span><span class="o">=</span><span class="n">array</span><span class="p">,</span>
<span class="n">y</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">array</span><span class="p">],</span>
<span class="n">mode</span><span class="o">=</span><span class="s1">&#39;markers&#39;</span><span class="p">,</span>
<span class="n">marker</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span>
<span class="n">size</span><span class="o">=</span><span class="p">[</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">j</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">array</span><span class="p">]</span>
<span class="p">),</span>
<span class="n">name</span><span class="o">=</span><span class="s1">&#39;array&#39;</span>
<span class="p">)</span>
<span class="n">trace2</span> <span class="o">=</span> <span class="n">go</span><span class="o">.</span><span class="n">Scatter</span><span class="p">(</span>
<span class="n">x</span><span class="o">=</span><span class="n">longer_array</span><span class="p">,</span>
<span class="n">y</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">longer_array</span><span class="p">],</span>
<span class="n">mode</span><span class="o">=</span><span class="s1">&#39;markers&#39;</span><span class="p">,</span>
<span class="n">marker</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span>
<span class="n">size</span><span class="o">=</span><span class="p">[</span><span class="mi">5</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">j</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">longer_array</span><span class="p">]</span>
<span class="p">),</span>
<span class="n">name</span><span class="o">=</span><span class="s1">&#39;longer_array&#39;</span>
<span class="p">)</span>

<span class="n">py</span><span class="o">.</span><span class="n">iplot</span><span class="p">([</span><span class="n">trace1</span><span class="p">,</span> <span class="n">trace2</span><span class="p">],</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;numpy-array&#39;</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area"><div class="prompt output_prompt">Out[2]:</div>

<div class="output_html rendered_html output_subarea output_execute_result">
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="https://plot.ly/~AdamKulidjian/1688.embed" height="525px" width="100%"></iframe>
</div>

</div>

</div>
</div>

</div>{% endraw %}
216 changes: 216 additions & 0 deletions _posts/numpy/append/Append.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### New to Plotly?\n",
"Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).\n",
"<br>You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/python/getting-started/#start-plotting-online).\n",
"<br>We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Imports\n",
"This tutorial imports [Numpy](http://www.numpy.org/)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'1.11.2'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"np.__version__"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Append Data\n",
"\n",
"Very similar in application to the core Python list method `.append()`, the `np.append()` function takes an `array` and some `values` in the form of an array and extends the length of the given array and adds the given item at the end."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~AdamKulidjian/1688.embed\" height=\"525px\" width=\"100%\"></iframe>"
],
"text/plain": [
"<plotly.tools.PlotlyDisplay object>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import plotly.plotly as py\n",
"import plotly.graph_objs as go\n",
"from plotly import tools\n",
"from plotly.tools import FigureFactory as FF\n",
"\n",
"array = np.array([1, 2, 3, 4, 5])\n",
"longer_array = np.append(array, [6, 7, 8])\n",
"\n",
"trace1 = go.Scatter(\n",
" x=array,\n",
" y=[1 for i in array],\n",
" mode='markers',\n",
" marker=dict(\n",
" size=[5 + 3*j for j in array]\n",
" ),\n",
" name='array'\n",
")\n",
"trace2 = go.Scatter(\n",
" x=longer_array,\n",
" y=[2 for j in longer_array],\n",
" mode='markers',\n",
" marker=dict(\n",
" size=[5 + 3*j for j in longer_array]\n",
" ),\n",
" name='longer_array'\n",
")\n",
"\n",
"py.iplot([trace1, trace2], filename='numpy-array')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting git+https://github.com/plotly/publisher.git\n",
" Cloning https://github.com/plotly/publisher.git to /var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-uPqS8w-build\n",
"Installing collected packages: publisher\n",
" Found existing installation: publisher 0.10\n",
" Uninstalling publisher-0.10:\n",
" Successfully uninstalled publisher-0.10\n",
" Running setup.py install for publisher ... \u001b[?25l-\b \b\\\b \bdone\n",
"\u001b[?25hSuccessfully installed publisher-0.10\n",
"\u001b[33mYou are using pip version 8.1.2, however version 9.0.1 is available.\n",
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning:\n",
"\n",
"The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead.\n",
"\n",
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning:\n",
"\n",
"Did you \"Save\" this notebook before running this command? Remember to save, always save.\n",
"\n"
]
}
],
"source": [
"from IPython.display import display, HTML\n",
"\n",
"display(HTML('<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />'))\n",
"display(HTML('<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">'))\n",
"\n",
"! pip install git+https://github.com/plotly/publisher.git --upgrade\n",
"import publisher\n",
"publisher.publish(\n",
" 'Append.ipynb', 'numpy/append/', 'Append | plotly',\n",
" 'How to append values to a NumPy array.',\n",
" title = 'Append | plotly',\n",
" name = 'Append',\n",
" has_thumbnail='true', thumbnail='thumbnail/numpy_array.jpg', \n",
" language='numpy', page_type='example_index',\n",
" display_as='modify-the-array', order=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 3d2992a

Please sign in to comment.