mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
added image 'csv-2d-multivariate-distributions'
This commit is contained in:
parent
ddac88526e
commit
5dd282f596
6 changed files with 4162 additions and 0 deletions
35
tikz/csv-2d-gaussian-multivarate-distributions/Makefile
Normal file
35
tikz/csv-2d-gaussian-multivarate-distributions/Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
SOURCE = csv-2d-gaussian-multivarate-distributions
|
||||
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:
|
||||
make
|
||||
#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
|
||||
rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
|
||||
inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
|
||||
rm $(SOURCE)2.svg
|
3
tikz/csv-2d-gaussian-multivarate-distributions/README.md
Normal file
3
tikz/csv-2d-gaussian-multivarate-distributions/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
|
@ -0,0 +1,83 @@
|
|||
\documentclass[varwidth=true, border=5pt]{article}
|
||||
\usepackage[active,tightpage]{preview}
|
||||
\usepackage[latin1]{inputenc}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{pgfplots}
|
||||
\pgfplotsset{compat=1.10}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows,positioning}
|
||||
\usepackage{helvet}
|
||||
\usepackage[eulergreek]{sansmath}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
width=13.4cm,
|
||||
height=10.0cm,
|
||||
% Grid
|
||||
grid = major,
|
||||
% size
|
||||
xmin= 40, % start the diagram at this x-coordinate
|
||||
xmax= 90, % end the diagram at this x-coordinate
|
||||
ymin= 0, % start the diagram at this y-coordinate
|
||||
ymax= 60, % end the diagram at this y-coordinate
|
||||
% Legende
|
||||
legend style={
|
||||
font=\large\sansmath\sffamily,
|
||||
at={(0.5,-0.18)},
|
||||
anchor=north,
|
||||
legend cell align=left,
|
||||
legend columns=-1,
|
||||
column sep=0.5cm
|
||||
},
|
||||
% Ticks
|
||||
tick align=inside,
|
||||
every axis/.append style={font=\large\sansmath\sffamily},
|
||||
minor tick style={thick},
|
||||
scaled y ticks = false,
|
||||
% Axis
|
||||
axis line style = {very thick,shorten <=-0.5\pgflinewidth},
|
||||
axis lines = middle,
|
||||
axis line style = very thick,
|
||||
xlabel=Gesamtausgaben,
|
||||
x label style={at={(axis description cs:0.5,-0.05)},
|
||||
anchor=north,
|
||||
font=\boldmath\sansmath\sffamily\Large},
|
||||
ylabel=Luxusausgaben,
|
||||
y label style={at={(axis description cs:-0.05,0.5)},
|
||||
anchor=south,
|
||||
rotate=90,
|
||||
font=\boldmath\sansmath\sffamily\Large},
|
||||
]
|
||||
\addplot[
|
||||
scatter,
|
||||
only marks,
|
||||
point meta=explicit symbolic,
|
||||
scatter/classes={
|
||||
a={mark=x,red!90!black},%
|
||||
b={mark=x,cyan!50!black}},
|
||||
]
|
||||
table[col sep=comma, meta=label] {data.csv};
|
||||
|
||||
\addplot[
|
||||
scatter,
|
||||
only marks,
|
||||
point meta=explicit symbolic,
|
||||
scatter/classes={
|
||||
b={mark=*,mark size=3pt,red!30!white,draw=black},%
|
||||
c={mark=*,mark size=3pt,cyan!30!white,draw=black},%
|
||||
a={mark=*,mark size=3pt,green!70!black,draw=black}},
|
||||
]
|
||||
table[meta=label] {
|
||||
x y label
|
||||
65 35 a
|
||||
70 40 b
|
||||
60 20 c
|
||||
};
|
||||
% \addlegendentry{Gruppe 1}
|
||||
% \addlegendentry{Gruppe 2}
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
4001
tikz/csv-2d-gaussian-multivarate-distributions/data.csv
Normal file
4001
tikz/csv-2d-gaussian-multivarate-distributions/data.csv
Normal file
File diff suppressed because it is too large
Load diff
40
tikz/csv-2d-gaussian-multivarate-distributions/multivariate-random.py
Executable file
40
tikz/csv-2d-gaussian-multivarate-distributions/multivariate-random.py
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy
|
||||
import csv
|
||||
|
||||
cov = [[25, 20], [20, 25]] # diagonal covariance, points lie on x or y-axis
|
||||
|
||||
meanI = [70, 40]
|
||||
datapointsI = 2000
|
||||
|
||||
meanII = [60, 20]
|
||||
datapointsII = 2000
|
||||
|
||||
dataI = numpy.random.multivariate_normal(meanI, cov, datapointsI).T
|
||||
x, y = dataI
|
||||
plt.plot(x, y, 'x')
|
||||
|
||||
dataII = numpy.random.multivariate_normal(meanII, cov, datapointsII).T
|
||||
x, y = dataII
|
||||
plt.plot(x, y, 'x')
|
||||
|
||||
plt.axis('equal')
|
||||
plt.show()
|
||||
|
||||
data = []
|
||||
xs, ys = dataI
|
||||
for x, y in zip(xs, ys):
|
||||
data.append([x, y, 'a'])
|
||||
xs, ys = dataII
|
||||
for x, y in zip(xs, ys):
|
||||
data.append([x, y, 'b'])
|
||||
|
||||
# Write data to csv files
|
||||
with open("data.csv", 'wb') as csvfile:
|
||||
csvfile.write("x,y,label\n")
|
||||
spamwriter = csv.writer(csvfile, delimiter=',',
|
||||
quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
||||
for datapoint in data:
|
||||
spamwriter.writerow(datapoint)
|
Loading…
Add table
Add a link
Reference in a new issue