TransWikia.com

How to fit the Histogram inside the node of tikzpicture

TeX - LaTeX Asked on August 11, 2021

I want to fix the x-axis label position and I also want to know how to reposition the histogram inside the rectangle like margin center or other feasible solution

documentclass{article}
usepackage[dvipsnames]{xcolor}
usepackage{tikz}
usetikzlibrary{positioning,calc}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
tikzset{myblock/.style = {rectangle, draw, minimum height=3cm}
}
  begin{tikzpicture}
    node (foo)[myblock]{
       begin{tikzpicture}
       begin{axis}[
       ybar=-0.10cm,
       axis x line*=bottom,
       axis y line*=left,
       height=3.5cm, width=3.4cm,
       bar width=0.1cm,
       symbolic x coords={topic1,topic2,topic3},
       %xtick={topic1,topic2,topic3},
       label style={font=tiny},
       tick label style={font=tiny}]
    addplot[BlueGreen,fill] coordinates {(topic1,0.4)};
    addplot[Cyan,fill] coordinates {(topic2,0.5)};
    addplot[ForestGreen,fill] coordinates {(topic3,0.1)};
      
    end{axis}
    end{tikzpicture}     
};
node (bar)[myblock,right of=foo,xshift=5cm]{bar};
draw[->] ($(foo.north east)!0.25!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.25!(bar.south west)$);
draw[->] ($(foo.north east)!0.5!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.5!(bar.south west)$);
draw[->] ($(foo.north east)!0.75!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.75!(bar.south west)$);
% more arrows here
end{tikzpicture}
newpage
end{document}

enter image description here

One Answer

enter image description here

documentclass{article}
usepackage[dvipsnames]{xcolor}
usepackage{tikz}
usetikzlibrary{positioning,calc, fit}
usepackage{pgfplots}
pgfplotsset{compat=newest}
begin{document}
    tikzset{myblock/.style = {rectangle, draw, minimum height=3cm}
    }
    begin{tikzpicture}
%       node (foo)[myblock]{
%           begin{tikzpicture}
                begin{axis}[
                    ybar=-0.10cm,
                    axis x line*=bottom,
                    axis y line*=left,
                    height=3.5cm, width=3.4cm,
                    bar width=0.1cm,
                    symbolic x coords={topic1,topic2,topic3},
                    %xtick={topic1,topic2,topic3},
                    label style={font=tiny},
                    tick label style={font=tiny}]
                    addplot[BlueGreen,fill] coordinates {(topic1,0.4)};
                    addplot[Cyan,fill] coordinates {(topic2,0.5)};
                    addplot[ForestGreen,fill] coordinates {(topic3,0.1)};
                    
                end{axis}
            (bounding box)
            node[draw=red, fit=(current bounding box)]{};
            draw(current bounding box.east)--++(2,0);
%           end{tikzpicture}     
%       };
%       node (bar)[myblock,right of=foo,xshift=5cm]{bar};
%       draw[->] ($(foo.north east)!0.25!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.25!(bar.south west)$);
%       draw[->] ($(foo.north east)!0.5!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.5!(bar.south west)$);
%       draw[->] ($(foo.north east)!0.75!(foo.south east)$) -- node[below] {arrow text} ($(bar.north west)!0.75!(bar.south west)$);
        % more arrows here
    end{tikzpicture}
%   newpage
end{document}

Answered by js bibra on August 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP