修复绘图中的比例

修复绘图中的比例

我该如何修复这个问题?它似乎有一个固定的比例。

钾

\documentclass{standalone}
\usepackage{tikz}
\usepackage{lmodern}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\pgfplotsset{
    legend image code/.code={
        \draw [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
    },
}
\pgfplotsset{grid style={dashed,gray}}
\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,black}}
\pgfplotsset{compat=newest}

\pgfplotsset{width=9cm,compat=1.8}
\pgfplotsset{
    /pgfplots/bar cycle list/.style={/pgfplots/cycle list={
            {black,fill=myblue,mark=none},
            {black,fill=myred,mark=none},
            {black,fill=mygray,mark=none},
        }, }}



\begin{document}


            \begin{tikzpicture}
            \begin{axis}[
            width=11cm,
%           xlabel={$L$ Vecinos m\'as cercanos},
            ylabel={Recall},
%           enlargelimits=0.09,
            set layers,
            ybar=1.9pt,
            area legend,
            bar width=11pt,
    xtick align=inside,
ytick align=inside,
            xtick={500,700,900,1100,1300,1900,2300,2900},
            samples=8,
            legend cell align=left,
            ymax=0.9111,
%           enlarge x limits=0.15,
            grid= both,
            x label style={font={ \tiny }},
            y label style={font={{\tiny } }},
            yticklabel style={/pgf/number format/fixed,
                /pgf/number format/precision=4},
            ticklabel style={font={\tiny }},
%           enlarge x limits=0.1,
            xticklabels = {
                $L=500$,
                $L=700$,
                $L=900$,
                $L=1100$,
                $L=1300$,
                $L=1900$,
                $L=2300$,
                $L=2900$
            },
            legend style={at={(0.01,.92)},anchor=west,font={\tiny }},
grid=none
            ]




            \addplot[black,fill=blue] coordinates {
        (500,0.9058) (700,0.9068) (900,0.9072) (1100,0.9073) (1300,0.9074) (1900,0.9074) (2300,0.9074) (2900,0.9074)
            };
            \addlegendentry{Blabla}

            \addplot[black,fill=black] coordinates {


(500,0.8878) (700,0.8879) (900,0.8879) (1100,0.8879) (1300,0.8880) (1900,0.8880) (2300,0.8880) (2900,0.8880)

            };
            \addlegendentry{Blabla}
            %% 
            \addplot[black,fill=green] coordinates {

(500,0.8765) (700,0.8765) (900,0.8765) (1100,0.8765) (1300,0.8765) (1900,0.8765) (2300,0.8765) (2900,0.8765)

            };
            \addlegendentry{Blabla}
            \end{axis}
            \end{tikzpicture}


\end{document}

答案1

如果你把尺寸缩小bar width到 4.5pt,并且像你指出的那样修复标签,那么你就会得到

\documentclass{standalone}
\usepackage{tikz}
\usepackage{lmodern}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\pgfplotsset{
    legend image code/.code={
        \draw [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
    },
}
\pgfplotsset{grid style={dashed,gray}}
\pgfplotsset{minor grid style={dashed,red}}
\pgfplotsset{major grid style={dotted,black}}
\pgfplotsset{compat=newest}

\pgfplotsset{width=9cm,compat=1.8}
\pgfplotsset{
    /pgfplots/bar cycle list/.style={/pgfplots/cycle list={
            {black,fill=myblue,mark=none},
            {black,fill=myred,mark=none},
            {black,fill=mygray,mark=none},
        }, }}



\begin{document}


            \begin{tikzpicture}
            \begin{axis}[
            width=11cm,
%           xlabel={$L$ Vecinos m\'as cercanos},
            ylabel={Recall},
%           enlargelimits=0.09,
            set layers,
            ybar=1.9pt,
            area legend,
            bar width=4.5pt,
    xtick align=inside,
     xticklabel style={
        rotate=-45,
        anchor=north west},
ytick align=inside,
            xtick={500,700,900,1100,1300,1900,2300,2900},
            samples=8,
            legend cell align=left,
            ymax=0.9111,
%           enlarge x limits=0.15,
            grid= both,
            x label style={font={ \tiny }},
            y label style={font={{\tiny } }},
            yticklabel style={/pgf/number format/fixed,
                /pgf/number format/precision=4},
            ticklabel style={font={\tiny }},
%           enlarge x limits=0.1,
            xticklabels = {
                $L=500$,
                $L=700$,
                $L=900$,
                $L=1100$,
                $L=1300$,
                $L=1900$,
                $L=2300$,
                $L=2900$
            },
            legend style={at={(0.01,.92)},anchor=west,font={\tiny }},
grid=none
            ]




            \addplot[black,fill=blue] coordinates {
        (500,0.9058) (700,0.9068) (900,0.9072) (1100,0.9073) (1300,0.9074) (1900,0.9074) (2300,0.9074) (2900,0.9074)
            };
            \addlegendentry{Blabla}

            \addplot[black,fill=black] coordinates {


(500,0.8878) (700,0.8879) (900,0.8879) (1100,0.8879) (1300,0.8880) (1900,0.8880) (2300,0.8880) (2900,0.8880)

            };
            \addlegendentry{Blabla}
            %% 
            \addplot[black,fill=green] coordinates {

(500,0.8765) (700,0.8765) (900,0.8765) (1100,0.8765) (1300,0.8765) (1900,0.8765) (2300,0.8765) (2900,0.8765)

            };
            \addlegendentry{Blabla}
            \end{axis}
            \end{tikzpicture}


\end{document}

在此处输入图片描述

相关内容