Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
borderwidth: 3,
borderpad: 4,
text: '<i>Series Identification</i><br>' +
'<b>Year</b> '+(point.data.name) + '<br>' +
'<b>Year</b> ' + (point.data.name) + '<br>' +
'<i>Point Identification</i><br>' +
'<b>Month</b> '+ (months[point.pointNumber]) +
'<br><i>Point Values</i><br>' +
Expand Down
32 changes: 16 additions & 16 deletions _posts/python/fundamentals/privacy/2015-06-30-privacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</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>.
<h4 id="New-to-Plotly?">New to Plotly?<a class="anchor-link" href="#New-to-Plotly?">&#194;&#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>
<h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check">&#182;</a></h4><p>Plotly's python package is updated frequently. Run <code>pip install plotly --upgrade</code> to use the latest version.</p>
<h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check">&#194;&#182;</a></h4><p>Plotly's python package is updated frequently. Run <code>pip install plotly --upgrade</code> to use the latest version.</p>

</div>
</div>
Expand All @@ -32,7 +32,7 @@ <h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check"
<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">plotly</span>
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">import</span> <span class="nn">plotly</span>
<span class="n">plotly</span><span class="o">.</span><span class="n">__version__</span>
</pre></div>

Expand Down Expand Up @@ -65,7 +65,7 @@ <h4 id="Version-Check">Version Check<a class="anchor-link" href="#Version-Check"
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Default-Privacy">Default Privacy<a class="anchor-link" href="#Default-Privacy">&#182;</a></h4><p>By default, <code>plotly.iplot()</code> and <code>plotly.plot()</code> create public graphs (which are free to create). With a <a href="https://plot.ly/plans">plotly subscription</a> you can easily make charts private or secret via the sharing argument.</p>
<h4 id="Default-Privacy">Default Privacy<a class="anchor-link" href="#Default-Privacy">&#194;&#182;</a></h4><p>By default, <code>plotly.iplot()</code> and <code>plotly.plot()</code> create public graphs (which are free to create). With a <a href="https://plot.ly/plans">plotly subscription</a> you can easily make charts private or secret via the sharing argument.</p>

</div>
</div>
Expand All @@ -74,7 +74,7 @@ <h4 id="Default-Privacy">Default Privacy<a class="anchor-link" href="#Default-Pr
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Public-Graphs">Public Graphs<a class="anchor-link" href="#Public-Graphs">&#182;</a></h4>
<h4 id="Public-Graphs">Public Graphs<a class="anchor-link" href="#Public-Graphs">&#194;&#182;</a></h4>
</div>
</div>
</div>
Expand Down Expand Up @@ -166,7 +166,7 @@ <h4 id="Public-Graphs">Public Graphs<a class="anchor-link" href="#Public-Graphs"
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Private-Graphs">Private Graphs<a class="anchor-link" href="#Private-Graphs">&#182;</a></h3>
<h3 id="Private-Graphs">Private Graphs<a class="anchor-link" href="#Private-Graphs">&#194;&#182;</a></h3>
</div>
</div>
</div>
Expand Down Expand Up @@ -248,7 +248,7 @@ <h3 id="Private-Graphs">Private Graphs<a class="anchor-link" href="#Private-Grap
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Secret-Graphs">Secret Graphs<a class="anchor-link" href="#Secret-Graphs">&#182;</a></h3>
<h3 id="Secret-Graphs">Secret Graphs<a class="anchor-link" href="#Secret-Graphs">&#194;&#182;</a></h3>
</div>
</div>
</div>
Expand Down Expand Up @@ -311,7 +311,7 @@ <h3 id="Secret-Graphs">Secret Graphs<a class="anchor-link" href="#Secret-Graphs"
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Make-All-Future-Plots-Private">Make All Future Plots Private<a class="anchor-link" href="#Make-All-Future-Plots-Private">&#182;</a></h3><p>To make all future plots private, you can update your configuration file to create private plots by default:</p>
<h3 id="Make-All-Future-Plots-Private">Make All Future Plots Private<a class="anchor-link" href="#Make-All-Future-Plots-Private">&#194;&#182;</a></h3><p>To make all future plots private, you can update your configuration file to create private plots by default:</p>

</div>
</div>
Expand All @@ -321,7 +321,7 @@ <h3 id="Make-All-Future-Plots-Private">Make All Future Plots Private<a class="an
<div class="prompt input_prompt">In&nbsp;[8]:</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</span>
<div class=" highlight hl-ipython2"><pre><span></span><span class="kn">import</span> <span class="nn">plotly</span>
<span class="n">plotly</span><span class="o">.</span><span class="n">tools</span><span class="o">.</span><span class="n">set_config_file</span><span class="p">(</span><span class="n">world_readable</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">sharing</span><span class="o">=</span><span class="s1">&#39;private&#39;</span><span class="p">)</span>
</pre></div>

Expand All @@ -334,7 +334,7 @@ <h3 id="Make-All-Future-Plots-Private">Make All Future Plots Private<a class="an
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Make-All-Existing-Plots-Private">Make All Existing Plots Private<a class="anchor-link" href="#Make-All-Existing-Plots-Private">&#182;</a></h3><p>This example uses <a href="https://api.plot.ly/v2/">Plotly's REST API</a></p>
<h3 id="Make-All-Existing-Plots-Private">Make All Existing Plots Private<a class="anchor-link" href="#Make-All-Existing-Plots-Private">&#194;&#182;</a></h3><p>This example uses <a href="https://api.plot.ly/v2/">Plotly's REST API</a></p>

</div>
</div>
Expand Down Expand Up @@ -401,7 +401,7 @@ <h3 id="Make-All-Existing-Plots-Private">Make All Existing Plots Private<a class
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="n">headers</span><span class="p">)</span>
<span class="k">if</span> <span class="n">response</span><span class="o">.</span><span class="n">status_code</span> <span class="o">!=</span> <span class="mi">200</span><span class="p">:</span>
<span class="k">return</span>
<span class="n">page</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">content</span><span class="p">)</span>
<span class="n">page</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">content</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">))</span>
<span class="k">yield</span> <span class="n">page</span>
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
<span class="n">resource</span> <span class="o">=</span> <span class="n">page</span><span class="p">[</span><span class="s1">&#39;children&#39;</span><span class="p">][</span><span class="s1">&#39;next&#39;</span><span class="p">]</span>
Expand All @@ -410,7 +410,7 @@ <h3 id="Make-All-Existing-Plots-Private">Make All Existing Plots Private<a class
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">resource</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="n">headers</span><span class="p">)</span>
<span class="k">if</span> <span class="n">response</span><span class="o">.</span><span class="n">status_code</span> <span class="o">!=</span> <span class="mi">200</span><span class="p">:</span>
<span class="k">break</span>
<span class="n">page</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">content</span><span class="p">)</span>
<span class="n">page</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">content</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">))</span>
<span class="k">yield</span> <span class="n">page</span>

<span class="k">def</span> <span class="nf">make_all_plots_private</span><span class="p">(</span><span class="n">username</span><span class="p">,</span> <span class="n">page_size</span><span class="o">=</span><span class="mi">500</span><span class="p">):</span>
Expand Down Expand Up @@ -450,7 +450,7 @@ <h3 id="Make-All-Existing-Plots-Private">Make All Existing Plots Private<a class
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a></h3>
<h3 id="Reference">Reference<a class="anchor-link" href="#Reference">&#194;&#182;</a></h3>
</div>
</div>
</div>
Expand Down Expand Up @@ -480,7 +480,7 @@ <h3 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><

plot(figure_or_data, validate=True, **plot_options)
Create a unique url for this plot in Plotly and optionally open url.

plot_options keyword agruments:
filename (string) -- the name that will be associated with this figure
fileopt (&#39;new&#39; | &#39;overwrite&#39; | &#39;extend&#39; | &#39;append&#39;) -- &#39;new&#39; creates a
Expand Down Expand Up @@ -519,6 +519,6 @@ <h3 id="Reference">Reference<a class="anchor-link" href="#Reference">&#182;</a><
</div>

</div>



{% endraw %}
{% endraw %}
36 changes: 17 additions & 19 deletions _posts/python/fundamentals/privacy/privacy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,25 @@
" response = requests.get(url, auth=auth, headers=headers)\n",
" if response.status_code != 200:\n",
" return\n",
" page = json.loads(response.content)\n",
" page = json.loads(response.content.decode('utf-8'))\n",
" yield page\n",
" while True:\n",
" resource = page['children']['next'] \n",
" resource = page['children']['next']\n",
" if not resource:\n",
" break\n",
" response = requests.get(resource, auth=auth, headers=headers)\n",
" if response.status_code != 200:\n",
" break\n",
" page = json.loads(response.content)\n",
" page = json.loads(response.content.decode('utf-8'))\n",
" yield page\n",
" \n",
"\n",
"def make_all_plots_private(username, page_size=500):\n",
" for page in get_pages(username, page_size):\n",
" for x in range(0, len(page['children']['results'])):\n",
" fid = page['children']['results'][x]['fid']\n",
" requests.patch('https://api.plot.ly/v2/files/'+fid, {\"world_readable\": False}, auth=auth, headers=headers)\n",
" print('ALL of your plots are now private - visit: https://plot.ly/organize/home to view your private plots!') \n",
" \n",
" print('ALL of your plots are now private - visit: https://plot.ly/organize/home to view your private plots!')\n",
"\n",
"make_all_plots_private(username)"
]
},
Expand Down Expand Up @@ -383,7 +383,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -415,28 +415,26 @@
"output_type": "stream",
"text": [
"Collecting git+https://github.com/plotly/publisher.git\n",
" Cloning https://github.com/plotly/publisher.git to c:\\users\\brand\\appdata\\local\\temp\\pip-req-build-ucsyuey6\n",
" Cloning https://github.com/plotly/publisher.git to /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-req-build-xMOOVK\n",
"Building wheels for collected packages: publisher\n",
" Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n",
"\u001b[?25h Stored in directory: /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-ephem-wheel-cache-hHDWrB/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",
" Running setup.py install for publisher: started\n",
" Running setup.py install for publisher: finished with status 'done'\n",
"Successfully installed publisher-0.11\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Python27\\lib\\site-packages\\IPython\\nbconvert.py:13: ShimWarning:\n",
"\n",
"The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n",
"\n",
"C:\\Python27\\lib\\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"
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n",
" \"You should import from nbconvert instead.\", ShimWarning)\n",
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you \"Save\" this notebook before running this command? Remember to save, always save.\n",
" warnings.warn('Did you \"Save\" this notebook before running this command? '\n"
]
}
],
Expand Down Expand Up @@ -484,7 +482,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
"version": "2.7.12"
}
},
"nbformat": 4,
Expand Down
Loading