Generating tikz figure in latex
up vote
1
down vote
favorite
I am trying to generate a tikz
figure similar to
So far I made the following latex code:
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5]
[baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=1pt of BA1.north west] {$X$};
node[left=1pt of BA1.west] (N) {$N$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=1pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=1pt of BA2.west] (N2) {$N$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5][baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
Any suggestion how to complete my figure?
Second question: How can I make for instance a gamma distribution
just using tikz
? Is it possible?
tikz-pgf tikz-styles tikz-matrix distributions
add a comment |
up vote
1
down vote
favorite
I am trying to generate a tikz
figure similar to
So far I made the following latex code:
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5]
[baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=1pt of BA1.north west] {$X$};
node[left=1pt of BA1.west] (N) {$N$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=1pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=1pt of BA2.west] (N2) {$N$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5][baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
Any suggestion how to complete my figure?
Second question: How can I make for instance a gamma distribution
just using tikz
? Is it possible?
tikz-pgf tikz-styles tikz-matrix distributions
1
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to generate a tikz
figure similar to
So far I made the following latex code:
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5]
[baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=1pt of BA1.north west] {$X$};
node[left=1pt of BA1.west] (N) {$N$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=1pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=1pt of BA2.west] (N2) {$N$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5][baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
Any suggestion how to complete my figure?
Second question: How can I make for instance a gamma distribution
just using tikz
? Is it possible?
tikz-pgf tikz-styles tikz-matrix distributions
I am trying to generate a tikz
figure similar to
So far I made the following latex code:
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5]
[baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=1pt of BA1.north west] {$X$};
node[left=1pt of BA1.west] (N) {$N$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=1pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=1pt of BA2.west] (N2) {$N$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5][baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
Any suggestion how to complete my figure?
Second question: How can I make for instance a gamma distribution
just using tikz
? Is it possible?
tikz-pgf tikz-styles tikz-matrix distributions
tikz-pgf tikz-styles tikz-matrix distributions
asked 3 hours ago
Dalek
1897
1897
1
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago
add a comment |
1
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago
1
1
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Here is a proposal. Your baseline
s were correct except you put them into separate [...]
brackets. Other than that you may want to load the decorations.pathreplacing
library for the braces and so on. (I had to move some nodes to the left since they'd interfere with the braces otherwise.)
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning,decorations.pathreplacing}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5,baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=10pt of BA1.north west] {$X$};
node[left=10pt of BA1.west] (N) {$N$};
path (BA1.north west) -- (BA1.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA1.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA1.south west) -- (aux)
node[midway,left=3pt]{$X_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA1.north west)
node[midway,left=3pt]{$X_{-w}$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=10pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=10pt of BA2.west] (N2) {$N$};
path (BA2.north west) -- (BA2.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA2.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA2.south west) -- (aux)
node[midway,left=3pt]{$Z_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA2.north west)
node[midway,left=3pt]{$Z_{-w}$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5,baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
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. Your baseline
s were correct except you put them into separate [...]
brackets. Other than that you may want to load the decorations.pathreplacing
library for the braces and so on. (I had to move some nodes to the left since they'd interfere with the braces otherwise.)
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning,decorations.pathreplacing}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5,baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=10pt of BA1.north west] {$X$};
node[left=10pt of BA1.west] (N) {$N$};
path (BA1.north west) -- (BA1.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA1.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA1.south west) -- (aux)
node[midway,left=3pt]{$X_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA1.north west)
node[midway,left=3pt]{$X_{-w}$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=10pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=10pt of BA2.west] (N2) {$N$};
path (BA2.north west) -- (BA2.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA2.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA2.south west) -- (aux)
node[midway,left=3pt]{$Z_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA2.north west)
node[midway,left=3pt]{$Z_{-w}$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5,baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
add a comment |
up vote
2
down vote
accepted
Here is a proposal. Your baseline
s were correct except you put them into separate [...]
brackets. Other than that you may want to load the decorations.pathreplacing
library for the braces and so on. (I had to move some nodes to the left since they'd interfere with the braces otherwise.)
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning,decorations.pathreplacing}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5,baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=10pt of BA1.north west] {$X$};
node[left=10pt of BA1.west] (N) {$N$};
path (BA1.north west) -- (BA1.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA1.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA1.south west) -- (aux)
node[midway,left=3pt]{$X_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA1.north west)
node[midway,left=3pt]{$X_{-w}$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=10pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=10pt of BA2.west] (N2) {$N$};
path (BA2.north west) -- (BA2.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA2.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA2.south west) -- (aux)
node[midway,left=3pt]{$Z_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA2.north west)
node[midway,left=3pt]{$Z_{-w}$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5,baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Here is a proposal. Your baseline
s were correct except you put them into separate [...]
brackets. Other than that you may want to load the decorations.pathreplacing
library for the braces and so on. (I had to move some nodes to the left since they'd interfere with the braces otherwise.)
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning,decorations.pathreplacing}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5,baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=10pt of BA1.north west] {$X$};
node[left=10pt of BA1.west] (N) {$N$};
path (BA1.north west) -- (BA1.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA1.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA1.south west) -- (aux)
node[midway,left=3pt]{$X_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA1.north west)
node[midway,left=3pt]{$X_{-w}$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=10pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=10pt of BA2.west] (N2) {$N$};
path (BA2.north west) -- (BA2.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA2.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA2.south west) -- (aux)
node[midway,left=3pt]{$Z_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA2.north west)
node[midway,left=3pt]{$Z_{-w}$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5,baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
Here is a proposal. Your baseline
s were correct except you put them into separate [...]
brackets. Other than that you may want to load the decorations.pathreplacing
library for the braces and so on. (I had to move some nodes to the left since they'd interfere with the braces otherwise.)
documentclass{article}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{booktabs}
usepackage{caption}
usepackage{tikz}
usetikzlibrary{positioning,decorations.pathreplacing}
tikzset{
pics/BitArray/.style n args={2}{
code={begin{scope}[#2]
fill
foreach row [count=y] in {#1} {
foreach cell [count=x] in row {
ifnumcell=1 %
(x-1, -y+1) rectangle ++(1, -1)
fi
pgfextra{%
globalletmaxxx
globalletmaxyy
}%
}
}
;
draw[thin] (0, 0) grid[step=1] (maxx, -maxy);
end{scope}
}
}
}
begin{document}
[
begin{tikzpicture}[scale=5,baseline=(N.base)]
begin{scope}[local bounding box=BA1,scale=0.4]
foreach y in {0.2,0.4,...,1.8} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,2);
end{scope}
node[above=1pt of BA1] {$D$};
node[left=10pt of BA1.north west] {$X$};
node[left=10pt of BA1.west] (N) {$N$};
path (BA1.north west) -- (BA1.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA1.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA1.south west) -- (aux)
node[midway,left=3pt]{$X_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA1.north west)
node[midway,left=3pt]{$X_{-w}$};
end{tikzpicture}
~sim~
begin{tikzpicture}[baseline=(N2.base)]
begin{scope}[local bounding box=BA2,scale=0.5]
pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
end{scope}
node[left=10pt of BA2.north west] {$mathbf{Z}$};
node[above=1pt of BA2] {$K$};
node[left=10pt of BA2.west] (N2) {$N$};
path (BA2.north west) -- (BA2.south west) coordinate[pos=0.8] (aux);
draw[line width=1pt,blue,fill=blue,fill opacity=0.2]
([xshift=-0.25pt,yshift=0.25pt]aux) rectangle ([xshift=0.25pt,yshift=-0.25pt]BA2.south east);
draw[thick,decorate,decoration={brace,raise=3pt}] (BA2.south west) -- (aux)
node[midway,left=3pt]{$Z_{w}$};
draw[thick,decorate,decoration={brace,raise=3pt}] (aux) -- (BA2.north west)
node[midway,left=3pt]{$Z_{-w}$};
end{tikzpicture}
~dots~*
begin{tikzpicture}[scale=5,baseline=(dots.base)]
begin{scope}[local bounding box=BA3,scale=0.4]
foreach y in {0.2,0.4,...,0.6} {
foreach x in {0.2,0.4,...,1.2} {
pgfmathparse{0.9*rnd+0.01}
definecolor{MyColor}{rgb}{pgfmathresult,pgfmathresult,pgfmathresult}
node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (x,y) {};
}
}
draw[step=.2,help lines] (0,0) grid (1.4,0.8);
end{scope}
node[below=1pt of BA3.south] (dots) {$vdots$};
end{tikzpicture}
]
end{document}
answered 2 hours ago
marmot
80.4k491172
80.4k491172
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%2f463073%2fgenerating-tikz-figure-in-latex%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
1
As for your second question: yes, it is possible, see here. (Generally it is better two ask two separate question. There is no charge.)
– marmot
3 hours ago
@marmot awesome thanks!
– Dalek
2 hours ago