Skip to content

update scientific charts for plotly v3 #1184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 48 additions & 17 deletions _posts/python/scientific/quiver/2015-06-30-quiver.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
<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">
Expand Down Expand Up @@ -45,12 +45,14 @@ <h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check"


<div class="output_area">

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




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

</div>
Expand All @@ -59,8 +61,7 @@ <h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check"
</div>

</div>
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
<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">
Expand Down Expand Up @@ -95,9 +96,11 @@ <h4 id="Basic-Quiver-Plot">Basic Quiver Plot<a class="anchor-link" href="#Basic-


<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/~PythonPlotBot/467.embed" height="525px" width="100%"></iframe>
</div>
Expand All @@ -108,8 +111,7 @@ <h4 id="Basic-Quiver-Plot">Basic Quiver Plot<a class="anchor-link" href="#Basic-
</div>

</div>
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
<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">
Expand All @@ -119,7 +121,7 @@ <h4 id="Quiver-Plot-with-Points">Quiver Plot with Points<a class="anchor-link" h
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="prompt input_prompt">In&nbsp;[3]:</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>
Expand Down Expand Up @@ -147,7 +149,7 @@ <h4 id="Quiver-Plot-with-Points">Quiver Plot with Points<a class="anchor-link" h
<span class="n">name</span><span class="o">=</span><span class="s1">&#39;points&#39;</span><span class="p">)</span>

<span class="c1"># Add points to figure</span>
<span class="n">fig</span><span class="p">[</span><span class="s1">&#39;data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
<span class="n">fig</span><span class="o">.</span><span class="n">add_trace</span><span class="p">(</span><span class="n">points</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">fig</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;Quiver with Points&#39;</span><span class="p">)</span>
</pre></div>
Expand All @@ -161,11 +163,13 @@ <h4 id="Quiver-Plot-with-Points">Quiver Plot with Points<a class="anchor-link" h


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

<div class="prompt output_prompt">Out[3]:</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/2513.embed" height="525px" width="100%"></iframe>
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="https://plot.ly/~PythonPlotBot/469.embed" height="525px" width="100%"></iframe>
</div>

</div>
Expand All @@ -174,8 +178,7 @@ <h4 id="Quiver-Plot-with-Points">Quiver Plot with Points<a class="anchor-link" h
</div>

</div>
<div class="cell border-box-sizing text_cell rendered">
<div class="prompt input_prompt">
<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">
Expand All @@ -185,7 +188,7 @@ <h4 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="prompt input_prompt">In&nbsp;[4]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython2"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">ff</span><span class="o">.</span><span class="n">create_quiver</span><span class="p">)</span>
Expand All @@ -200,12 +203,14 @@ <h4 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>Help on function create_quiver in module plotly.figure_factory._quiver:

create_quiver(x, y, u, v, scale=0.1, arrow_scale=0.3, angle=0.3490658503988659, **kwargs)
create_quiver(x, y, u, v, scale=0.1, arrow_scale=0.3, angle=0.3490658503988659, scaleratio=None, **kwargs)
Returns data for a quiver plot.

:param (list|ndarray) x: x coordinates of the arrow locations
Expand All @@ -217,6 +222,9 @@ <h4 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><
:param (float in [0,1]) arrow_scale: value multiplied to length of barb
to get length of arrowhead. Default = .3
:param (angle in radians) angle: angle of arrowhead. Default = pi/9
:param (positive float) scaleratio: the ratio between the scale of the y-axis
and the scale of the x-axis (scale_y / scale_x). Default = None, the
scale ratio is not fixed.
:param kwargs: kwargs passed through plotly.graph_objs.Scatter
for more information on valid kwargs call
help(plotly.graph_objs.Scatter)
Expand Down Expand Up @@ -271,14 +279,37 @@ <h4 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><

# Create quiver
fig = create_quiver(x, y, u, v, scale=.2, arrow_scale=.3, angle=math.pi/6,
name=&#39;Wind Velocity&#39;, line=Line(width=1))
name=&#39;Wind Velocity&#39;, line=dict(width=1))

# Add title to layout
fig[&#39;layout&#39;].update(title=&#39;Quiver Plot&#39;)

# Plot
py.plot(fig, filename=&#39;quiver&#39;)
```

Example 4: Forcing a fix scale ratio to maintain the arrow length
```
import plotly.plotly as py
from plotly.figure_factory import create_quiver

import numpy as np

# Add data
x,y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5))
u = x
v = y
angle = np.arctan(v / u)
norm = 0.25
u = norm * np.cos(angle)
v = norm * np.sin(angle)

# Create quiver with a fix scale ratio
fig = create_quiver(x, y, u, v, scale = 1, scaleratio = 0.5)

# Plot
py.plot(fig, filename=&#39;quiver&#39;)
```

</pre>
</div>
Expand Down
Loading