Skip to content

Commit f3b9cd1

Browse files
authored
Merge pull request #1266 from plotly/py-latex-doc-update
updated python latex doc
2 parents 454c5e8 + af55a6c commit f3b9cd1

File tree

4 files changed

+336
-51
lines changed

4 files changed

+336
-51
lines changed

_posts/python/style/latex/2015-04-09-latex.html

Lines changed: 0 additions & 36 deletions
This file was deleted.

_posts/python/style/latex/2015-04-09-latex_python_index.html

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
permalink: python/LaTeX/
3+
description: How to add LaTeX to python graphs.
4+
name: LaTeX
5+
has_thumbnail: true
6+
thumbnail: thumbnail/latex.jpg
7+
title: Python LaTeX | Examples | Plotly
8+
has_thumbnail: true
9+
language: python
10+
display_as: style_opt
11+
order: 3
12+
ipynb: ~notebook_demo/268
13+
layout: user-guide
14+
page_type: u-guide
15+
---
16+
{% raw %}
17+
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
18+
</div><div class="inner_cell">
19+
<div class="text_cell_render border-box-sizing rendered_html">
20+
<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>.
21+
<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>.
22+
<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>
23+
24+
</div>
25+
</div>
26+
</div>
27+
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
28+
</div><div class="inner_cell">
29+
<div class="text_cell_render border-box-sizing rendered_html">
30+
<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>
31+
32+
</div>
33+
</div>
34+
</div>
35+
<div class="cell border-box-sizing code_cell rendered">
36+
<div class="input">
37+
<div class="prompt input_prompt">In&nbsp;[1]:</div>
38+
<div class="inner_cell">
39+
<div class="input_area">
40+
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">plotly</span>
41+
<span class="n">plotly</span><span class="o">.</span><span class="n">__version__</span>
42+
</pre></div>
43+
44+
</div>
45+
</div>
46+
</div>
47+
48+
<div class="output_wrapper">
49+
<div class="output">
50+
51+
52+
<div class="output_area">
53+
54+
<div class="prompt output_prompt">Out[1]:</div>
55+
56+
57+
58+
59+
<div class="output_text output_subarea output_execute_result">
60+
<pre>&#39;3.6.0&#39;</pre>
61+
</div>
62+
63+
</div>
64+
65+
</div>
66+
</div>
67+
68+
</div>
69+
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
70+
</div><div class="inner_cell">
71+
<div class="text_cell_render border-box-sizing rendered_html">
72+
<h4 id="LaTeX-Typesetting">LaTeX Typesetting<a class="anchor-link" href="#LaTeX-Typesetting">&#182;</a></h4>
73+
</div>
74+
</div>
75+
</div>
76+
<div class="cell border-box-sizing code_cell rendered">
77+
<div class="input">
78+
<div class="prompt input_prompt">In&nbsp;[2]:</div>
79+
<div class="inner_cell">
80+
<div class="input_area">
81+
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">import</span> <span class="nn">plotly.plotly</span> <span class="k">as</span> <span class="nn">py</span>
82+
<span class="kn">import</span> <span class="nn">plotly.graph_objs</span> <span class="k">as</span> <span class="nn">go</span>
83+
84+
<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>
85+
<span class="n">x</span><span class="o">=</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>
86+
<span class="n">y</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">16</span><span class="p">],</span>
87+
<span class="n">name</span><span class="o">=</span><span class="sa">r</span><span class="s1">&#39;$\alpha_</span><span class="si">{1c}</span><span class="s1"> = 352 \pm 11 \text{ km s}^{-1}$&#39;</span>
88+
<span class="p">)</span>
89+
<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>
90+
<span class="n">x</span><span class="o">=</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>
91+
<span class="n">y</span><span class="o">=</span><span class="p">[</span><span class="mf">0.5</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">4.5</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
92+
<span class="n">name</span><span class="o">=</span><span class="sa">r</span><span class="s1">&#39;$\beta_</span><span class="si">{1c}</span><span class="s1"> = 25 \pm 11 \text{ km s}^{-1}$&#39;</span>
93+
<span class="p">)</span>
94+
<span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">trace1</span><span class="p">,</span> <span class="n">trace2</span><span class="p">]</span>
95+
<span class="n">layout</span> <span class="o">=</span> <span class="n">go</span><span class="o">.</span><span class="n">Layout</span><span class="p">(</span>
96+
<span class="n">xaxis</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span>
97+
<span class="n">title</span><span class="o">=</span><span class="sa">r</span><span class="s1">&#39;$\sqrt{(n_\text</span><span class="si">{c}</span><span class="s1">(t|{T_\text</span><span class="si">{early}</span><span class="s1">}))}$&#39;</span>
98+
<span class="p">),</span>
99+
<span class="n">yaxis</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span>
100+
<span class="n">title</span><span class="o">=</span><span class="sa">r</span><span class="s1">&#39;$d, r \text{ (solar radius)}$&#39;</span>
101+
<span class="p">)</span>
102+
<span class="p">)</span>
103+
<span class="n">fig</span> <span class="o">=</span> <span class="n">go</span><span class="o">.</span><span class="n">Figure</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">layout</span><span class="o">=</span><span class="n">layout</span><span class="p">)</span>
104+
<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;latex&#39;</span><span class="p">)</span>
105+
</pre></div>
106+
107+
</div>
108+
</div>
109+
</div>
110+
111+
<div class="output_wrapper">
112+
<div class="output">
113+
114+
115+
<div class="output_area">
116+
117+
<div class="prompt output_prompt">Out[2]:</div>
118+
119+
120+
121+
<div class="output_html rendered_html output_subarea output_execute_result">
122+
<iframe id="igraph" scrolling="no" style="border:none;" seamless="seamless" src="https://plot.ly/~PythonPlotBot/3193.embed" height="525px" width="100%"></iframe>
123+
</div>
124+
125+
</div>
126+
127+
</div>
128+
</div>
129+
130+
</div>
131+
132+
133+
{% endraw %}
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#### New to Plotly?\n",
8+
"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",
9+
"<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",
10+
"<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!"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"metadata": {},
16+
"source": [
17+
"#### Version Check\n",
18+
"Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version."
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 1,
24+
"metadata": {},
25+
"outputs": [
26+
{
27+
"data": {
28+
"text/plain": [
29+
"'3.6.0'"
30+
]
31+
},
32+
"execution_count": 1,
33+
"metadata": {},
34+
"output_type": "execute_result"
35+
}
36+
],
37+
"source": [
38+
"import plotly\n",
39+
"plotly.__version__"
40+
]
41+
},
42+
{
43+
"cell_type": "markdown",
44+
"metadata": {},
45+
"source": [
46+
"#### LaTeX Typesetting"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": 2,
52+
"metadata": {},
53+
"outputs": [
54+
{
55+
"data": {
56+
"text/html": [
57+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://plot.ly/~PythonPlotBot/3193.embed\" height=\"525px\" width=\"100%\"></iframe>"
58+
],
59+
"text/plain": [
60+
"<plotly.tools.PlotlyDisplay object>"
61+
]
62+
},
63+
"execution_count": 2,
64+
"metadata": {},
65+
"output_type": "execute_result"
66+
}
67+
],
68+
"source": [
69+
"import plotly.plotly as py\n",
70+
"import plotly.graph_objs as go\n",
71+
"\n",
72+
"trace1 = go.Scatter(\n",
73+
" x=[1, 2, 3, 4],\n",
74+
" y=[1, 4, 9, 16],\n",
75+
" name=r'$\\alpha_{1c} = 352 \\pm 11 \\text{ km s}^{-1}$'\n",
76+
")\n",
77+
"trace2 = go.Scatter(\n",
78+
" x=[1, 2, 3, 4],\n",
79+
" y=[0.5, 2, 4.5, 8],\n",
80+
" name=r'$\\beta_{1c} = 25 \\pm 11 \\text{ km s}^{-1}$'\n",
81+
")\n",
82+
"data = [trace1, trace2]\n",
83+
"layout = go.Layout(\n",
84+
" xaxis=dict(\n",
85+
" title=r'$\\sqrt{(n_\\text{c}(t|{T_\\text{early}}))}$'\n",
86+
" ),\n",
87+
" yaxis=dict(\n",
88+
" title=r'$d, r \\text{ (solar radius)}$'\n",
89+
" )\n",
90+
")\n",
91+
"fig = go.Figure(data=data, layout=layout)\n",
92+
"py.iplot(fig, filename='latex')"
93+
]
94+
},
95+
{
96+
"cell_type": "code",
97+
"execution_count": 3,
98+
"metadata": {},
99+
"outputs": [
100+
{
101+
"data": {
102+
"text/html": [
103+
"<link href=\"//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700\" rel=\"stylesheet\" type=\"text/css\" />"
104+
],
105+
"text/plain": [
106+
"<IPython.core.display.HTML object>"
107+
]
108+
},
109+
"metadata": {},
110+
"output_type": "display_data"
111+
},
112+
{
113+
"data": {
114+
"text/html": [
115+
"<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">"
116+
],
117+
"text/plain": [
118+
"<IPython.core.display.HTML object>"
119+
]
120+
},
121+
"metadata": {},
122+
"output_type": "display_data"
123+
},
124+
{
125+
"name": "stdout",
126+
"output_type": "stream",
127+
"text": [
128+
"Collecting git+https://github.com/plotly/publisher.git\n",
129+
" Cloning https://github.com/plotly/publisher.git to c:\\users\\priyat~1\\appdata\\local\\temp\\pip-req-build-14xlc2tw\n",
130+
"Building wheels for collected packages: publisher\n",
131+
" Running setup.py bdist_wheel for publisher: started\n",
132+
" Running setup.py bdist_wheel for publisher: finished with status 'done'\n",
133+
" Stored in directory: C:\\Users\\PRIYAT~1\\AppData\\Local\\Temp\\pip-ephem-wheel-cache-qma0fxzy\\wheels\\99\\3e\\a0\\fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n",
134+
"Successfully built publisher\n",
135+
"Installing collected packages: publisher\n",
136+
" Found existing installation: publisher 0.13\n",
137+
" Uninstalling publisher-0.13:\n",
138+
" Successfully uninstalled publisher-0.13\n",
139+
"Successfully installed publisher-0.13\n"
140+
]
141+
},
142+
{
143+
"name": "stderr",
144+
"output_type": "stream",
145+
"text": [
146+
"C:\\Anaconda\\Anaconda3\\lib\\site-packages\\IPython\\nbconvert.py:13: ShimWarning:\n",
147+
"\n",
148+
"The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n",
149+
"\n",
150+
"C:\\Anaconda\\Anaconda3\\lib\\site-packages\\publisher\\publisher.py:53: UserWarning:\n",
151+
"\n",
152+
"Did you \"Save\" this notebook before running this command? Remember to save, always save.\n",
153+
"\n"
154+
]
155+
}
156+
],
157+
"source": [
158+
"from IPython.display import display, HTML\n",
159+
"\n",
160+
"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",
161+
"display(HTML('<link rel=\"stylesheet\" type=\"text/css\" href=\"http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css\">'))\n",
162+
"\n",
163+
"! pip install git+https://github.com/plotly/publisher.git --upgrade\n",
164+
"import publisher\n",
165+
"publisher.publish(\n",
166+
" 'latex-typesetting.ipynb', 'python/LaTeX/', 'LaTeX',\n",
167+
" 'How to add LaTeX to python graphs.',\n",
168+
" title = 'Python LaTeX | Examples | Plotly',\n",
169+
" has_thumbnail='true', thumbnail='thumbnail/latex.jpg',\n",
170+
" language='python',\n",
171+
" display_as='style_opt', order=3, ipynb='~notebook_demo/268')"
172+
]
173+
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": null,
177+
"metadata": {},
178+
"outputs": [],
179+
"source": []
180+
}
181+
],
182+
"metadata": {
183+
"kernelspec": {
184+
"display_name": "Python 3",
185+
"language": "python",
186+
"name": "python3"
187+
},
188+
"language_info": {
189+
"codemirror_mode": {
190+
"name": "ipython",
191+
"version": 3
192+
},
193+
"file_extension": ".py",
194+
"mimetype": "text/x-python",
195+
"name": "python",
196+
"nbconvert_exporter": "python",
197+
"pygments_lexer": "ipython3",
198+
"version": "3.7.1"
199+
}
200+
},
201+
"nbformat": 4,
202+
"nbformat_minor": 2
203+
}

0 commit comments

Comments
 (0)