Generating tikz figure in latex











up vote
1
down vote

favorite












I am trying to generate a tikz figure similar to
enter image description here



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?










share|improve this question


















  • 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















up vote
1
down vote

favorite












I am trying to generate a tikz figure similar to
enter image description here



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?










share|improve this question


















  • 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













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to generate a tikz figure similar to
enter image description here



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?










share|improve this question













I am trying to generate a tikz figure similar to
enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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














  • 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










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Here is a proposal. Your baselines 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}


enter image description here






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    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

























    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 baselines 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}


    enter image description here






    share|improve this answer

























      up vote
      2
      down vote



      accepted










      Here is a proposal. Your baselines 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}


      enter image description here






      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Here is a proposal. Your baselines 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}


        enter image description here






        share|improve this answer












        Here is a proposal. Your baselines 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}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        marmot

        80.4k491172




        80.4k491172






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt