How can I create the following graphic of raw data?
up vote
1
down vote
favorite
I've already tried different codes with tikzpicture
but especially the normal distribution graphs are giving me headaches.
Any ideas?
Would appreciate any kind of help!
That is what I have got so far, but I have no clue how to integrate the normal distributions ...
documentclass{article}
usepackage{tikzsymbols}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset};
addlegendentry{$E(Y | x_i)$}
coordinate (aux1) at (2,{slope*2+offset});
coordinate (aux2) at (2,2.5);
end{axis}
end{tikzpicture}
end{document}
tikz-styles
add a comment |
up vote
1
down vote
favorite
I've already tried different codes with tikzpicture
but especially the normal distribution graphs are giving me headaches.
Any ideas?
Would appreciate any kind of help!
That is what I have got so far, but I have no clue how to integrate the normal distributions ...
documentclass{article}
usepackage{tikzsymbols}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset};
addlegendentry{$E(Y | x_i)$}
coordinate (aux1) at (2,{slope*2+offset});
coordinate (aux2) at (2,2.5);
end{axis}
end{tikzpicture}
end{document}
tikz-styles
3
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
1
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I've already tried different codes with tikzpicture
but especially the normal distribution graphs are giving me headaches.
Any ideas?
Would appreciate any kind of help!
That is what I have got so far, but I have no clue how to integrate the normal distributions ...
documentclass{article}
usepackage{tikzsymbols}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset};
addlegendentry{$E(Y | x_i)$}
coordinate (aux1) at (2,{slope*2+offset});
coordinate (aux2) at (2,2.5);
end{axis}
end{tikzpicture}
end{document}
tikz-styles
I've already tried different codes with tikzpicture
but especially the normal distribution graphs are giving me headaches.
Any ideas?
Would appreciate any kind of help!
That is what I have got so far, but I have no clue how to integrate the normal distributions ...
documentclass{article}
usepackage{tikzsymbols}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset};
addlegendentry{$E(Y | x_i)$}
coordinate (aux1) at (2,{slope*2+offset});
coordinate (aux2) at (2,2.5);
end{axis}
end{tikzpicture}
end{document}
tikz-styles
tikz-styles
edited Dec 2 at 22:31
Kurt
34.5k846157
34.5k846157
asked Dec 2 at 22:00
Rebecca
513
513
3
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
1
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07
add a comment |
3
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
1
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07
3
3
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
1
1
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Here is a proposal: define a pic
for the Gaussian and place it wherever you want.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
tikzset{pics/.cd,
Gaussian/.style={code={
draw[gray] plot[variable=x,domain=-GaussDomain:GaussDomain] ({GaussHeight*exp(-2*x*x/GaussWidth)},x);
draw[gray,dashed] (0,0) -- (GaussHeight,0);
}}}
pgfkeys{Gauss width/.store in=GaussWidth,
Gauss width=0.5,
Gauss height/.store in=GaussHeight,
Gauss height=0.8,
Gauss domain/.store in=GaussDomain,
Gauss domain=1.2
}
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset}
coordinate[pos=0.3](p1) coordinate[pos=0.7](p2);
addlegendentry{$E(Y | x_i)$}
% coordinate (aux1) at (2,{slope*2+offset});
% coordinate (aux2) at (2,2.5);
end{axis}
path foreach X in {1,2} {(pX) pic{Gaussian}};
end{tikzpicture}
end{document}
You can adjust the width, height, domain or color of the Gaussian by setting the corresponding pgf keys accordingly.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Here is a proposal: define a pic
for the Gaussian and place it wherever you want.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
tikzset{pics/.cd,
Gaussian/.style={code={
draw[gray] plot[variable=x,domain=-GaussDomain:GaussDomain] ({GaussHeight*exp(-2*x*x/GaussWidth)},x);
draw[gray,dashed] (0,0) -- (GaussHeight,0);
}}}
pgfkeys{Gauss width/.store in=GaussWidth,
Gauss width=0.5,
Gauss height/.store in=GaussHeight,
Gauss height=0.8,
Gauss domain/.store in=GaussDomain,
Gauss domain=1.2
}
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset}
coordinate[pos=0.3](p1) coordinate[pos=0.7](p2);
addlegendentry{$E(Y | x_i)$}
% coordinate (aux1) at (2,{slope*2+offset});
% coordinate (aux2) at (2,2.5);
end{axis}
path foreach X in {1,2} {(pX) pic{Gaussian}};
end{tikzpicture}
end{document}
You can adjust the width, height, domain or color of the Gaussian by setting the corresponding pgf keys accordingly.
add a comment |
up vote
2
down vote
accepted
Here is a proposal: define a pic
for the Gaussian and place it wherever you want.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
tikzset{pics/.cd,
Gaussian/.style={code={
draw[gray] plot[variable=x,domain=-GaussDomain:GaussDomain] ({GaussHeight*exp(-2*x*x/GaussWidth)},x);
draw[gray,dashed] (0,0) -- (GaussHeight,0);
}}}
pgfkeys{Gauss width/.store in=GaussWidth,
Gauss width=0.5,
Gauss height/.store in=GaussHeight,
Gauss height=0.8,
Gauss domain/.store in=GaussDomain,
Gauss domain=1.2
}
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset}
coordinate[pos=0.3](p1) coordinate[pos=0.7](p2);
addlegendentry{$E(Y | x_i)$}
% coordinate (aux1) at (2,{slope*2+offset});
% coordinate (aux2) at (2,2.5);
end{axis}
path foreach X in {1,2} {(pX) pic{Gaussian}};
end{tikzpicture}
end{document}
You can adjust the width, height, domain or color of the Gaussian by setting the corresponding pgf keys accordingly.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Here is a proposal: define a pic
for the Gaussian and place it wherever you want.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
tikzset{pics/.cd,
Gaussian/.style={code={
draw[gray] plot[variable=x,domain=-GaussDomain:GaussDomain] ({GaussHeight*exp(-2*x*x/GaussWidth)},x);
draw[gray,dashed] (0,0) -- (GaussHeight,0);
}}}
pgfkeys{Gauss width/.store in=GaussWidth,
Gauss width=0.5,
Gauss height/.store in=GaussHeight,
Gauss height=0.8,
Gauss domain/.store in=GaussDomain,
Gauss domain=1.2
}
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset}
coordinate[pos=0.3](p1) coordinate[pos=0.7](p2);
addlegendentry{$E(Y | x_i)$}
% coordinate (aux1) at (2,{slope*2+offset});
% coordinate (aux2) at (2,2.5);
end{axis}
path foreach X in {1,2} {(pX) pic{Gaussian}};
end{tikzpicture}
end{document}
You can adjust the width, height, domain or color of the Gaussian by setting the corresponding pgf keys accordingly.
Here is a proposal: define a pic
for the Gaussian and place it wherever you want.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{pgfplotstable}
pgfplotstableread{
X Y
0 2
1 2.25
2 2.5
3 2.75
4 2
5 2.75
6 3
7 3.25
8 3.5
9 3.75
10 4
}datatable
tikzset{pics/.cd,
Gaussian/.style={code={
draw[gray] plot[variable=x,domain=-GaussDomain:GaussDomain] ({GaussHeight*exp(-2*x*x/GaussWidth)},x);
draw[gray,dashed] (0,0) -- (GaussHeight,0);
}}}
pgfkeys{Gauss width/.store in=GaussWidth,
Gauss width=0.5,
Gauss height/.store in=GaussHeight,
Gauss height=0.8,
Gauss domain/.store in=GaussDomain,
Gauss domain=1.2
}
begin{document}
pgfplotsset{every axis legend/.append style={
cells={anchor=west}}}
begin{tikzpicture}
begin{axis}[legend pos=north west,xmin=0,xmax=10,
ymin=0,ymax=5,enlargelimits=0.1]
addplot[draw=none,color=red] table [
x=X,
y={create col/linear regression={y=Y}},
] {datatable};
xdefslope{pgfplotstableregressiona}
xdefoffset{pgfplotstableregressionb}
addplot[no marks,color=red,domain=-2:9] {slope*x+offset}
coordinate[pos=0.3](p1) coordinate[pos=0.7](p2);
addlegendentry{$E(Y | x_i)$}
% coordinate (aux1) at (2,{slope*2+offset});
% coordinate (aux2) at (2,2.5);
end{axis}
path foreach X in {1,2} {(pX) pic{Gaussian}};
end{tikzpicture}
end{document}
You can adjust the width, height, domain or color of the Gaussian by setting the corresponding pgf keys accordingly.
edited Dec 3 at 3:59
answered Dec 2 at 22:39
marmot
81.7k491174
81.7k491174
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462859%2fhow-can-i-create-the-following-graphic-of-raw-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Please show us the code you have so far!
– Kurt
Dec 2 at 22:01
1
you can certainly provide code to draw everything else apart from the normal distribution curves, given the answer(s) to your previous question. so please do..
– Troy
Dec 2 at 22:07