File:Csv-2d-gaussian-multivarate-distributions.svg

Size of this PNG preview of this SVG file: 639 × 468 pixels. Other resolutions: 320 × 234 pixels | 640 × 469 pixels | 1,024 × 750 pixels | 1,280 × 937 pixels | 2,560 × 1,875 pixels.
Original file (SVG file, nominally 639 × 468 pixels, file size: 1.78 MB)
![]() | This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionCsv-2d-gaussian-multivarate-distributions.svg |
English: Multivariate Gaussian Distributions
Deutsch: Multiariate Gauss-Verteilungen
|
Date | |
Source | Own work |
Author | MartinThoma |
Source is available at github
LaTeX Code
\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}
Data
The data is available at GitHub. However, you can create similar data with the following Python code:
#!/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)
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
![]() ![]() |
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
some value
23 August 2014
image/svg+xml
3dedc2dba5d5d757692f644a98782c91c58db485
1,867,541 byte
468 pixel
639 pixel
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 00:56, 1 September 2014 | ![]() | 639 × 468 (1.78 MB) | wikimediacommons>MartinThoma | Added line where that divides both probabilities |
File usage
The following page uses this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Width | 511pt |
---|---|
Height | 374pt |