Skip to content

Instantly share code, notes, and snippets.

@windstriver
Created June 28, 2016 01:38
Show Gist options
  • Save windstriver/cb6c98411f4b92f057b0af2c4caa7659 to your computer and use it in GitHub Desktop.
Save windstriver/cb6c98411f4b92f057b0af2c4caa7659 to your computer and use it in GitHub Desktop.
Plot complex function using TikZ & Python
import numpy as np
def coth(x):
return np.cosh(x)/np.sinh(x)
def brilloutin(J, x):
if x == 0:
return 0
else:
return (2*J+1)/(2*J)*coth((2*J+1)/(2*J)*x) - 1/(2*J)*coth(1/(2*J)*x)
x = np.linspace(-5, 10, 1000)
y = np.zeros((len(x)))
for i in range(0, len(x)):
y[i] = brilloutin(1, x[i])
datafile = np.savetxt('data.dat', np.column_stack((x, y)))
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[
scale=3,
xscale=0.2,]
\draw[->] (-5,0) -- (10,0);
\draw[->] (0,-1) -- (0,1.5);
\draw plot file {data.dat};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment