0

I have 4 tikzpicture that I want to put them side by side in a one page width. But they overlap with each other. Can you please help me to fix this problem?

\documentclass[conference]{IEEEtran}

\usepackage{amsmath}
\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs}
\usepackage{caption,subcaption,tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\usepackage{multirow}
\usepackage{pgfplotstable}
\renewcommand*{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}[![enter image description here][1]][1]
\begin{document}

\begin{figure*}
    \centering
    \begin{subfigure}[b]{0.1\textwidth}
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm, width=15.5cm,
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.15,0.2,0.25,0.3,
            0.4,0.5,0.6,0.8,1.0},
        xtick=data,
        xlabel={year 2016},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.15, 81.2)
            (0.2, 77.7)
            (0.25, 79.5)
            (0.3, 78.8)
            (0.4, 81.4)
            (0.5, 81.7)
            (0.6, 82.6)
            (0.8, 7.0)
            (1.0, 83.9)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.1\textwidth}
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm, width=15.5cm,
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.25,0.3,0.4,0.5,
            0.6,0.8,1.0,1.2},
        xtick=data,
        xlabel={year 2013},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.25, 85.7)
            (0.3, 56.1)
            (0.4, 21.9)
            (0.5, 30.9)
            (0.6, 62.73)
            (0.8, 80.69)
            (1.0, 22.55)
            (1.2, 30.84)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.1\textwidth}
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Rate},
        height=8cm, width=15.5cm,
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.3,0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xtick=data,
        xlabel={Rate},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.3, 59.29)
            (0.4, 34.29)
            (0.5, 23.15)
            (0.6, 86.83)
            (0.8, 75.53)
            (1.0, 66.95)
            (1.2, 59.37)
            (1.6, 47.68)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.1\textwidth}
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm, width=15.5cm,
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xtick=data,
        xlabel={year 2016},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.4, 23.54)
            (0.5, 36.05)
            (0.6, 73.67)
            (0.8, 43.0)
            (1.0, 95.35)
            (1.2, 34.30)
            (1.6, 27.60)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \caption{Rate}
\end{figure*}
\end{document}
  • First, lose the subfigures. Without captions, they serve no purpose. Second, reduce the width (15.5cm *4 = 62.cm, or 31cm at scale=0.5). width={.5\textwidth} at scale=0.5 works. – John Kormylo Aug 19 '17 at 3:15
  • Maybe I did something wrong, but it does not work in this way. – user3104352 Aug 19 '17 at 3:47
1

While Zarko put more effort into it, he left useless subfigures in.

\documentclass[conference]{IEEEtran}

\usepackage{amsmath}
\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{algorithmic}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs}
\usepackage{caption,subcaption,tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\usepackage{multirow}
\usepackage{pgfplotstable}
\renewcommand*{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}%
\usepackage{showframe}% debugging tool
\begin{document}

\begin{figure*}
    \centering
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm, width={0.5\textwidth},
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.15,0.2,0.25,0.3,
            0.4,0.5,0.6,0.8,1.0},
        xtick=data,
        xlabel={year 2016},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.15, 81.2)
            (0.2, 77.7)
            (0.25, 79.5)
            (0.3, 78.8)
            (0.4, 81.4)
            (0.5, 81.7)
            (0.6, 82.6)
            (0.8, 7.0)
            (1.0, 83.9)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
%
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm,  width={0.5\textwidth},
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.25,0.3,0.4,0.5,
            0.6,0.8,1.0,1.2},
        xtick=data,
        xlabel={year 2013},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.25, 85.7)
            (0.3, 56.1)
            (0.4, 21.9)
            (0.5, 30.9)
            (0.6, 62.73)
            (0.8, 80.69)
            (1.0, 22.55)
            (1.2, 30.84)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
%
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Rate},
        height=8cm,  width={0.5\textwidth},
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.3,0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xtick=data,
        xlabel={Rate},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.3, 59.29)
            (0.4, 34.29)
            (0.5, 23.15)
            (0.6, 86.83)
            (0.8, 75.53)
            (1.0, 66.95)
            (1.2, 59.37)
            (1.6, 47.68)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
%
        \begin{tikzpicture}[scale=0.50]
        \centering
        \begin{axis}[
        ybar, axis on top,
        title={Calculation},
        height=8cm, width={0.5\textwidth},
        bar width=0.4cm,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        tickwidth=0pt,
        enlarge x limits=true,
        legend style={
            at={(0.5,-0.2)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
        },
        ylabel={Percentage (\%)},
        symbolic x coords={
            0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xtick=data,
        xlabel={year 2016},
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.4, 23.54)
            (0.5, 36.05)
            (0.6, 73.67)
            (0.8, 43.0)
            (1.0, 95.35)
            (1.2, 34.30)
            (1.6, 27.60)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
%
    \caption{Rate}
\end{figure*}
\end{document}

demo

  • i left subfigure in mwe in hope that OP will learn that determining their widths is not trivial. of course in this particular case they are surplus :-). – Zarko Aug 19 '17 at 13:37
1

enter image description here

changes:

  • widths of sub figures (it had to has width bigger from width of its content)
  • ylabel has only the first graph
  • increase scale to 0.6
  • image width is decreased to 80 mm (before scaling)
  • rotate xtick label
  • common axis options are collected in pgfplotssetfor this figure

\documentclass[conference]{IEEEtran}

\usepackage{amsmath}
%\usepackage{balance}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{algorithmic}
%\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{booktabs, multirow}
\usepackage{caption, subcaption}
\usepackage{pgfplotstable}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.3}
\newcommand\fnote[1]{\captionsetup{font=small}\caption*{#1}}

\renewcommand*{\familydefault}{\sfdefault}

\begin{document}

\begin{figure*}
\pgfplotsset{% for this figure
        width=80mm,
        ybar, axis on top,
        ymajorgrids, tick align=inside,
        major grid style={draw=white},
        enlarge y limits={value=.1,upper},
        ymin=0, ymax=100,
        axis x line*=bottom,
        axis y line*=left,
        y axis line style={opacity=0},
        xtick=data,
        xticklabel style={rotate=90,
                          anchor=east},
        tickwidth=0pt,
        enlarge x limits=true,
        xlabel style={at={(0.5,-0.18)},
                          anchor=north},
        legend style={
            at={(0.5,-0.3)},
            anchor=north,
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
                     },
        nodes near coords={
            \pgfmathprintnumber[precision=0]{\pgfplotspointmeta}}
            }% end of common pgflotsset
    \centering
    \begin{subfigure}[b]{0.26\textwidth}
        \begin{tikzpicture}[scale=0.6]
        \begin{axis}[
        title={Calculation},
        symbolic x coords={
            0.15, 0.2, 0.25,0.3,
            0.4,0.5,0.6,0.8,1.0},
        bar width=0.4cm,
        ylabel={Percentage (\%)},
        xlabel={year 2016},
            ]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.15, 81.2)
            (0.2, 77.7)
            (0.25, 79.5)
            (0.3, 78.8)
            (0.4, 81.4)
            (0.5, 81.7)
            (0.6, 82.6)
            (0.8, 7.0)
            (1.0, 83.9)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.24\textwidth}
        \begin{tikzpicture}[scale=0.6]
        \begin{axis}[
        title={Calculation},
        bar width=0.4cm,
        symbolic x coords={
            0.25,0.3,0.4,0.5,
            0.6,0.8,1.0,1.2},
        xlabel={year 2013},
                    ]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.25, 85.7)
            (0.3, 56.1)
            (0.4, 21.9)
            (0.5, 30.9)
            (0.6, 62.73)
            (0.8, 80.69)
            (1.0, 22.55)
            (1.2, 30.84)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.24\textwidth}
        \begin{tikzpicture}[scale=0.6]
        \begin{axis}[
        title={Rate},
        bar width=0.4cm,
        symbolic x coords={
            0.3,0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xlabel={Rate},
                        ]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.3, 59.29)
            (0.4, 34.29)
            (0.5, 23.15)
            (0.6, 86.83)
            (0.8, 75.53)
            (1.0, 66.95)
            (1.2, 59.37)
            (1.6, 47.68)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}[b]{0.24\textwidth}
        \begin{tikzpicture}[scale=0.6]
        \begin{axis}[
       title={Calculation},
        bar width=0.4cm,
        symbolic x coords={
            0.4,0.5,0.6,
            0.8,1.0,1.2, 1.6},
        xlabel={year 2016},
                    ]
        \addplot [draw=none, fill=black!60] coordinates {
            (0.4, 23.54)
            (0.5, 36.05)
            (0.6, 73.67)
            (0.8, 43.0)
            (1.0, 95.35)
            (1.2, 34.30)
            (1.6, 27.60)
        };
        \legend{First Fix, Second Fix}
        \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \caption{Rate}
\end{figure*}
\end{document}

note:

  • i commented package, which i havent
  • image is very small, i suggest to consider to have only two, not scaled in line
  • it is not clear why you use subfigure environments. the same result you obtained if omit them in between tikzpictures put\hfill

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.