forked from MartinThoma/LaTeX-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f1684d
commit 2a30558
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
SOURCE = pi | ||
DELAY = 80 | ||
DENSITY = 300 | ||
WIDTH = 512 | ||
|
||
make: | ||
pdflatex $(SOURCE).tex -output-format=pdf | ||
make clean | ||
|
||
clean: | ||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot | ||
|
||
gif: | ||
pdfcrop $(SOURCE).pdf | ||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif | ||
make clean | ||
|
||
png: | ||
make | ||
make svg | ||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png | ||
|
||
transparentGif: | ||
convert $(SOURCE).pdf -transparent white result.gif | ||
make clean | ||
|
||
svg: | ||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg | ||
pdf2svg $(SOURCE).pdf $(SOURCE).svg | ||
# Necessary, as pdf2svg does not always create valid svgs: | ||
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Compiled example | ||
---------------- | ||
![Example](pi.png) | ||
|
||
|
||
Credits | ||
------- | ||
Cristian Ilies Vasile made this kind of image first: | ||
|
||
https://img.washingtonpost.com/wp-apps/imrs.php?src=https%3A%2F%2Fimg.washingtonpost.com%2Fblogs%2Fwonkblog%2Ffiles%2F2015%2F03%2Flinks-pi-cristian.png&w=1484 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Create a data.csv file.""" | ||
|
||
import csv | ||
|
||
try: | ||
# import version included with old SymPy | ||
from sympy.mpmath import mp | ||
except ImportError: | ||
# import newer version | ||
from mpmath import mp | ||
|
||
mp.dps = 1000 # set number of digits | ||
pi = mp.pi | ||
print(pi) | ||
|
||
# Split pi in groups of two digits | ||
pi = str(pi)[2:] | ||
split_pi = [] | ||
for i in range(0, len(pi), 2): | ||
part = pi[i:i + 2] | ||
if len(part) != 2: | ||
continue | ||
split_pi.append(part) | ||
|
||
# Representation of pi | ||
data = [("x", "y", "color")] # header | ||
for e1, e2 in zip(split_pi, split_pi[1:]): | ||
tuple_date = (int(e1), int(e2), "c{}".format(int(int(e1) / 10))) | ||
data.append(tuple_date) | ||
|
||
# Write data to csv | ||
with open('data.csv', 'w') as fp: | ||
writer = csv.writer(fp, delimiter=',') | ||
writer.writerows(data) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
\documentclass{standalone} | ||
\usepackage{amssymb} | ||
\usepackage{tikz} | ||
\usepackage[utf8]{inputenc} | ||
\usepackage{csvsimple} | ||
\usepackage{xcolor} | ||
|
||
\definecolor{c0}{HTML}{5A311D} | ||
\definecolor{c1}{HTML}{E18B4E} | ||
\definecolor{c2}{HTML}{4A1776} | ||
\definecolor{c3}{HTML}{C966DA} | ||
\definecolor{c4}{HTML}{04676C} | ||
\definecolor{c5}{HTML}{0CE7E1} | ||
\definecolor{c6}{HTML}{004692} | ||
\definecolor{c7}{HTML}{0082FF} | ||
\definecolor{c8}{HTML}{355128} | ||
\definecolor{c9}{HTML}{DF1C24} | ||
|
||
\begin{document} | ||
\newcommand{\distance}{6} | ||
|
||
\begin{tikzpicture} | ||
\foreach \a in {0,1,...,100}{ | ||
\node[draw=none](\a) at (\a/100*360: \distance) {} ; | ||
} | ||
\csvreader[ head to column names]% | ||
{data.csv}{}{% | ||
\path (\x) edge [bend right, \color] (\y); | ||
} | ||
\end{tikzpicture} | ||
\end{document} |