Skip to content

Commit 6b12612

Browse files
committed
update pythontex example
1 parent 361b8c8 commit 6b12612

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

latex/pythontex/pythontex.tex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,18 @@ \subsection{Native SymPy Support}
9494

9595
\pagebreak
9696

97-
\subsection{Block of code}
97+
\subsection{Code block with a plot}
9898

99-
... with a plot:
99+
The session is \verb|pycode| to be distinct from the \verb|default| session.
100+
This allows \pytex\ to speed up the execution by running the sympy code and the plot below in parallel.
100101

101-
\begin{pycode}
102+
\begin{pycode}[pycode]
102103
from pylab import *
103104
# Define f(t), the desired function to plot
104105
def f(t):
105-
return cos(2 * pi * t) * exp(-t)
106+
return cos(2 * pi * exp(t)) * exp(-t)
106107
# Generate the points (t_i, y_i) to plot
107-
t = linspace(0, 5, 500)
108+
t = linspace(0, 4, 1000)
108109
y = f(t)
109110
# Begin with an empty plot, 5 x 3 inches
110111
clf()
@@ -114,7 +115,7 @@ \subsection{Block of code}
114115
# Generate the plot with annotations
115116
plot(t, y)
116117
title("Damped exponential decay")
117-
text(3, 0.15, r"$y = \cos(2 \pi t) e^{-t}$")
118+
text(2.5, 0.4, r"$y = \cos(2 \pi \exp(t)) e^{-t}$")
118119
xlabel("time (s)")
119120
ylabel("voltage (mV)")
120121
# Save the plot as a PDF file

0 commit comments

Comments
 (0)