diff --git a/_posts/python/scientific/quiver/2015-06-30-quiver.html b/_posts/python/scientific/quiver/2015-06-30-quiver.html index a38c3738b7d7..42219777db75 100644 --- a/_posts/python/scientific/quiver/2015-06-30-quiver.html +++ b/_posts/python/scientific/quiver/2015-06-30-quiver.html @@ -10,12 +10,12 @@ title: Python Quiver Plots | plotly display_as: scientific has_thumbnail: true -order: 12 ipynb: ~notebook_demo/42 +order: 12 +page_type: u-guide --- {% raw %} -
import plotly.plotly as py
@@ -147,7 +149,7 @@ Quiver Plot with Pointsname='points')
# Add points to figure
-fig['data'].append(points)
+fig.add_trace(points)
py.iplot(fig, filename='Quiver with Points')
help(ff.create_quiver)
@@ -200,12 +203,14 @@ Reference¶<
+
+
-
+
@@ -32,7 +32,7 @@ Version CheckIn [1]:
-import plotly
+import plotly
plotly.__version__
@@ -45,12 +45,14 @@ Version Check
+
Out[1]:
+
@@ -59,8 +61,7 @@ Version Check
-
-
+
@@ -73,10 +74,10 @@ Basic Streamline PlotIn [2]:
-import plotly.plotly as py
-import plotly.figure_factory as ff
+import plotly.plotly as py
+import plotly.figure_factory as ff
-import numpy as np
+import numpy as np
x = np.linspace(-3, 3, 100)
y = np.linspace(-3, 3, 100)
@@ -98,21 +99,11 @@ Basic Streamline Plot
-
-
-
-
-
-
-
+
@@ -137,11 +127,11 @@ Streamline and Source Point PlotIn [3]:
-import plotly.plotly as py
-import plotly.figure_factory as ff
-import plotly.graph_objs as go
+import plotly.plotly as py
+import plotly.figure_factory as ff
+import plotly.graph_objs as go
-import numpy as np
+import numpy as np
N = 50
x_start, x_end = -2.0, 2.0
@@ -165,11 +155,11 @@ Streamline and Source Point Plot# Add source point
source_point = go.Scatter(x=[x_source], y=[y_source],
mode='markers',
- marker=go.Marker(size=14),
+ marker=go.scatter.Marker(size=14),
name='source point')
# Add source point to figure
-fig['data'].append(source_point)
+fig.add_trace(source_point)
py.iplot(fig, filename='streamline_source')
@@ -182,9 +172,11 @@ Streamline and Source Point Plot
+
Out[3]:
+
@@ -195,8 +187,7 @@ Streamline and Source Point Plot
-
diff --git a/_posts/python/scientific/quiver/quiver.ipynb b/_posts/python/scientific/quiver/quiver.ipynb
index 9c27bc985896..893800bd0e00 100644
--- a/_posts/python/scientific/quiver/quiver.ipynb
+++ b/_posts/python/scientific/quiver/quiver.ipynb
@@ -2,10 +2,7 @@
"cells": [
{
"cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
+ "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",
@@ -18,16 +15,12 @@
{
"cell_type": "code",
"execution_count": 1,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "'2.0.2'"
+ "'3.4.1'"
]
},
"execution_count": 1,
@@ -42,10 +35,7 @@
},
{
"cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"source": [
"#### Basic Quiver Plot"
]
@@ -53,11 +43,7 @@
{
"cell_type": "code",
"execution_count": 2,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"outputs": [
{
"data": {
@@ -89,10 +75,7 @@
},
{
"cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"source": [
"#### Quiver Plot with Points"
]
@@ -100,11 +83,7 @@
{
"cell_type": "code",
"execution_count": 3,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"outputs": [
{
"data": {
@@ -146,17 +125,14 @@
" name='points')\n",
"\n",
"# Add points to figure\n",
- "fig['data'].append(points)\n",
+ "fig.add_trace(points)\n",
"\n",
"py.iplot(fig, filename='Quiver with Points')"
]
},
{
"cell_type": "markdown",
- "metadata": {
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"source": [
"#### Reference "
]
@@ -164,11 +140,7 @@
{
"cell_type": "code",
"execution_count": 4,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
+ "metadata": {},
"outputs": [
{
"name": "stdout",
@@ -176,7 +148,7 @@
"text": [
"Help on function create_quiver in module plotly.figure_factory._quiver:\n",
"\n",
- "create_quiver(x, y, u, v, scale=0.1, arrow_scale=0.3, angle=0.3490658503988659, **kwargs)\n",
+ "create_quiver(x, y, u, v, scale=0.1, arrow_scale=0.3, angle=0.3490658503988659, scaleratio=None, **kwargs)\n",
" Returns data for a quiver plot.\n",
" \n",
" :param (list|ndarray) x: x coordinates of the arrow locations\n",
@@ -188,6 +160,9 @@
" :param (float in [0,1]) arrow_scale: value multiplied to length of barb\n",
" to get length of arrowhead. Default = .3\n",
" :param (angle in radians) angle: angle of arrowhead. Default = pi/9\n",
+ " :param (positive float) scaleratio: the ratio between the scale of the y-axis\n",
+ " and the scale of the x-axis (scale_y / scale_x). Default = None, the\n",
+ " scale ratio is not fixed.\n",
" :param kwargs: kwargs passed through plotly.graph_objs.Scatter\n",
" for more information on valid kwargs call\n",
" help(plotly.graph_objs.Scatter)\n",
@@ -242,7 +217,7 @@
" \n",
" # Create quiver\n",
" fig = create_quiver(x, y, u, v, scale=.2, arrow_scale=.3, angle=math.pi/6,\n",
- " name='Wind Velocity', line=Line(width=1))\n",
+ " name='Wind Velocity', line=dict(width=1))\n",
" \n",
" # Add title to layout\n",
" fig['layout'].update(title='Quiver Plot')\n",
@@ -250,6 +225,29 @@
" # Plot\n",
" py.plot(fig, filename='quiver')\n",
" ```\n",
+ " \n",
+ " Example 4: Forcing a fix scale ratio to maintain the arrow length\n",
+ " ```\n",
+ " import plotly.plotly as py\n",
+ " from plotly.figure_factory import create_quiver\n",
+ " \n",
+ " import numpy as np\n",
+ " \n",
+ " # Add data\n",
+ " x,y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5))\n",
+ " u = x\n",
+ " v = y\n",
+ " angle = np.arctan(v / u)\n",
+ " norm = 0.25\n",
+ " u = norm * np.cos(angle)\n",
+ " v = norm * np.sin(angle)\n",
+ " \n",
+ " # Create quiver with a fix scale ratio\n",
+ " fig = create_quiver(x, y, u, v, scale = 1, scaleratio = 0.5)\n",
+ " \n",
+ " # Plot\n",
+ " py.plot(fig, filename='quiver')\n",
+ " ```\n",
"\n"
]
}
@@ -260,12 +258,8 @@
},
{
"cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "collapsed": false,
- "deletable": true,
- "editable": true
- },
+ "execution_count": 1,
+ "metadata": {},
"outputs": [
{
"data": {
@@ -292,17 +286,22 @@
"output_type": "display_data"
},
{
- "name": "stderr",
+ "name": "stdout",
"output_type": "stream",
"text": [
- "/usr/local/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",
- "/usr/local/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"
+ "Collecting git+https://github.com/plotly/publisher.git\n",
+ " Cloning https://github.com/plotly/publisher.git to /tmp/pip-req-build-_Duvic\n",
+ "Building wheels for collected packages: publisher\n",
+ " Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n",
+ "\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-RODQO4/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n",
+ "Successfully built publisher\n",
+ "Installing collected packages: publisher\n",
+ " Found existing installation: publisher 0.11\n",
+ " Uninstalling publisher-0.11:\n",
+ " Successfully uninstalled publisher-0.11\n",
+ "Successfully installed publisher-0.11\n",
+ "\u001b[33mYou are using pip version 10.0.1, however version 18.1 is available.\n",
+ "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
]
}
],
@@ -329,9 +328,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "collapsed": true,
- "deletable": true,
- "editable": true
+ "collapsed": true
},
"outputs": [],
"source": []
@@ -353,9 +350,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
- "version": "2.7.12"
+ "version": "2.7.15rc1"
}
},
"nbformat": 4,
- "nbformat_minor": 0
+ "nbformat_minor": 2
}
diff --git a/_posts/python/scientific/streamline/2015-06-30-streamline.html b/_posts/python/scientific/streamline/2015-06-30-streamline.html
index 4d6d44dd9ec1..d0dacb924264 100644
--- a/_posts/python/scientific/streamline/2015-06-30-streamline.html
+++ b/_posts/python/scientific/streamline/2015-06-30-streamline.html
@@ -10,12 +10,12 @@
title: Python Streamline Plots | plotly
display_as: scientific
has_thumbnail: true
-order: 13
ipynb: ~notebook_demo/43
+order: 13
+page_type: u-guide
---
{% raw %}
-