我如何增加刻度之间的间距,使第一个刻度更靠近轴,并从 pgfplot 中删除空白?

我如何增加刻度之间的间距,使第一个刻度更靠近轴,并从 pgfplot 中删除空白?

问题标题说明了一切,我的图看起来不太好看。我想增加每个 xtick 之间的间距,使第一个 xtick 更靠近 y 轴,并删除图右侧没有 x 刻度的那个空间。

如果可能的话,请说明如何设置每个图例的颜色/绘图,因为每个图例列都有很多共同点,所以我想让同一列中的每个图例具有相同的颜色但不同的绘图。我不知道是否有人会理解这一点,但我试过了。

输出如下:

输出

我的代码很长,但它在这里:

    \documentclass{standalone}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}

    \usepackage{pgfplots}



    \begin{document}

    \begin{tikzpicture}
    \begin{axis}[
    height=10cm,
    width=15cm,
    grid=major,
    legend columns = 3,
    legend style={
    at={(0.5,-0.15)},
    anchor = north},
    xtick = data,
    xlabel = Rodadas,
    ylabel = Qualidade,
    ]


\addplot coordinates {
(1, 0.678806)
(2, 0.707318)
(3, 0.735688)
(4, 0.758773)
(5, 0.850093)
(6, 0.850093)
(7, 0.850093)
(8, 0.850093)
(9, 0.850093)
(10, 0.871927)
(11, 0.871927)
(12, 0.871927)
(13, 0.871927)
(14, 0.871927)
(15, 0.871927)
(16, 0.873799)
(17, 0.875102)
(18, 0.914746)
(19, 0.914746)
(20, 0.914746)
(21, 0.914746)
(22, 0.914746)
(23, 0.914746)
(24, 0.914746)
(25, 0.914746)
(26, 0.914746)
(27, 0.914746)
(28, 0.914746)
(29, 0.914746)
(30, 0.914746)
};

\addplot coordinates {
(1, 0.755057)
(2, 0.770508)
(3, 0.786410)
(4, 0.817386)
(5, 0.835345)
(6, 0.837206)
(7, 0.841269)
(8, 0.850456)
(9, 0.855433)
(10, 0.856709)
(11, 0.865922)
(12, 0.866900)
(13, 0.884384)
(14, 0.904939)
(15, 0.909285)
(16, 0.909285)
(17, 0.912864)
(18, 0.922196)
(19, 0.942011)
(20, 0.945971)
(21, 0.945971)
(22, 0.946822)
(23, 0.949695)
(24, 0.951748)
(25, 0.955744)
(26, 0.955744)
(27, 0.955744)
(28, 0.955744)
(29, 0.955744)
(30, 0.955830)
};

\addplot coordinates {
(1, 0.779965)
(2, 0.805282)
(3, 0.822174)
(4, 0.831721)
(5, 0.871130)
(6, 0.883848)
(7, 0.889126)
(8, 0.891892)
(9, 0.915892)
(10, 0.932662)
(11, 0.937660)
(12, 0.941063)
(13, 0.954651)
(14, 0.954651)
(15, 0.954651)
(16, 0.954651)
(17, 0.955258)
(18, 0.964528)
(19, 0.964528)
(20, 0.966332)
(21, 0.972416)
(22, 0.973069)
(23, 0.973069)
(24, 0.973069)
(25, 0.975399)
(26, 0.976746)
(27, 0.978759)
(28, 0.986392)
(29, 0.989421)
(30, 0.989421)
};

\addplot coordinates {
(1, 0.248592)
(2, 0.270525)
(3, 0.270525)
(4, 0.274079)
(5, 0.274079)
(6, 0.274079)
(7, 0.276394)
(8, 0.276394)
(9, 0.276394)
(10, 0.276394)
(11, 0.277121)
(12, 0.277121)
(13, 0.277121)
(14, 0.277121)
(15, 0.277121)
(16, 0.277121)
(17, 0.277121)
(18, 0.277121)
(19, 0.291238)
(20, 0.291238)
(21, 0.308117)
(22, 0.316756)
(23, 0.316756)
(24, 0.316756)
(25, 0.316756)
(26, 0.316756)
(27, 0.316756)
(28, 0.316756)
(29, 0.316756)
(30, 0.316756)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.301701)
(4, 0.301701)
(5, 0.301701)
(6, 0.347555)
(7, 0.347555)
(8, 0.347555)
(9, 0.347555)
(10, 0.347555)
(11, 0.347555)
(12, 0.347555)
(13, 0.347555)
(14, 0.347555)
(15, 0.347555)
(16, 0.347555)
(17, 0.347555)
(18, 0.347555)
(19, 0.369908)
(20, 0.372418)
(21, 0.372418)
(22, 0.372418)
(23, 0.372418)
(24, 0.372418)
(25, 0.372418)
(26, 0.372418)
(27, 0.372418)
(28, 0.372418)
(29, 0.372418)
(30, 0.372418)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.308213)
(4, 0.309166)
(5, 0.310629)
(6, 0.324628)
(7, 0.324628)
(8, 0.335789)
(9, 0.338966)
(10, 0.346886)
(11, 0.349949)
(12, 0.350236)
(13, 0.355030)
(14, 0.358046)
(15, 0.358046)
(16, 0.360049)
(17, 0.360609)
(18, 0.363103)
(19, 0.367216)
(20, 0.368751)
(21, 0.372306)
(22, 0.376436)
(23, 0.376436)
(24, 0.376436)
(25, 0.376892)
(26, 0.380644)
(27, 0.380780)
(28, 0.385106)
(29, 0.389572)
(30, 0.390048)
};


    \legend{32-2 com busca local, 128-4 com busca local, 256-8 com busca local, 32-2 sem busca local, 128-4 sem busca local, 256-8 sem busca local}



    \end{axis}
    \end{tikzpicture}

    \end{document}

答案1

要删除左右边缘的空白区域,可以设置enlarge x limits=false

要影响绘图样式,您可以提供类似于选项的选项red, mark=*\addplot [...]也可以设置cycle list采用绘图样式列表的选项。

    \documentclass{standalone}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}

    \usepackage{pgfplots}



    \begin{document}

    \begin{tikzpicture}
    \begin{axis}[
    height=10cm,
    width=15cm,
    grid=major,
    enlarge x limits=false,
    legend columns = 3,
    legend style={
    at={(0.5,-0.15)},
    anchor = north},
    xtick = data,
    xlabel = Rodadas,
    ylabel = Qualidade,
    cycle list={
        cyan, mark=*, mark options={fill=white}\\
        orange, mark=*, mark options={fill=white}\\
        green!70!black, mark=*, mark options={fill=white}\\
        cyan, mark=*, mark options={fill=gray!80}\\
        orange, mark=*, mark options={fill=gray!80}\\
        green!70!black, mark=*, mark options={fill=gray!80}\\
    }
    ]


\addplot coordinates {
(1, 0.678806)
(2, 0.707318)
(3, 0.735688)
(4, 0.758773)
(5, 0.850093)
(6, 0.850093)
(7, 0.850093)
(8, 0.850093)
(9, 0.850093)
(10, 0.871927)
(11, 0.871927)
(12, 0.871927)
(13, 0.871927)
(14, 0.871927)
(15, 0.871927)
(16, 0.873799)
(17, 0.875102)
(18, 0.914746)
(19, 0.914746)
(20, 0.914746)
(21, 0.914746)
(22, 0.914746)
(23, 0.914746)
(24, 0.914746)
(25, 0.914746)
(26, 0.914746)
(27, 0.914746)
(28, 0.914746)
(29, 0.914746)
(30, 0.914746)
};

\addplot coordinates {
(1, 0.755057)
(2, 0.770508)
(3, 0.786410)
(4, 0.817386)
(5, 0.835345)
(6, 0.837206)
(7, 0.841269)
(8, 0.850456)
(9, 0.855433)
(10, 0.856709)
(11, 0.865922)
(12, 0.866900)
(13, 0.884384)
(14, 0.904939)
(15, 0.909285)
(16, 0.909285)
(17, 0.912864)
(18, 0.922196)
(19, 0.942011)
(20, 0.945971)
(21, 0.945971)
(22, 0.946822)
(23, 0.949695)
(24, 0.951748)
(25, 0.955744)
(26, 0.955744)
(27, 0.955744)
(28, 0.955744)
(29, 0.955744)
(30, 0.955830)
};

\addplot coordinates {
(1, 0.779965)
(2, 0.805282)
(3, 0.822174)
(4, 0.831721)
(5, 0.871130)
(6, 0.883848)
(7, 0.889126)
(8, 0.891892)
(9, 0.915892)
(10, 0.932662)
(11, 0.937660)
(12, 0.941063)
(13, 0.954651)
(14, 0.954651)
(15, 0.954651)
(16, 0.954651)
(17, 0.955258)
(18, 0.964528)
(19, 0.964528)
(20, 0.966332)
(21, 0.972416)
(22, 0.973069)
(23, 0.973069)
(24, 0.973069)
(25, 0.975399)
(26, 0.976746)
(27, 0.978759)
(28, 0.986392)
(29, 0.989421)
(30, 0.989421)
};

\addplot coordinates {
(1, 0.248592)
(2, 0.270525)
(3, 0.270525)
(4, 0.274079)
(5, 0.274079)
(6, 0.274079)
(7, 0.276394)
(8, 0.276394)
(9, 0.276394)
(10, 0.276394)
(11, 0.277121)
(12, 0.277121)
(13, 0.277121)
(14, 0.277121)
(15, 0.277121)
(16, 0.277121)
(17, 0.277121)
(18, 0.277121)
(19, 0.291238)
(20, 0.291238)
(21, 0.308117)
(22, 0.316756)
(23, 0.316756)
(24, 0.316756)
(25, 0.316756)
(26, 0.316756)
(27, 0.316756)
(28, 0.316756)
(29, 0.316756)
(30, 0.316756)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.301701)
(4, 0.301701)
(5, 0.301701)
(6, 0.347555)
(7, 0.347555)
(8, 0.347555)
(9, 0.347555)
(10, 0.347555)
(11, 0.347555)
(12, 0.347555)
(13, 0.347555)
(14, 0.347555)
(15, 0.347555)
(16, 0.347555)
(17, 0.347555)
(18, 0.347555)
(19, 0.369908)
(20, 0.372418)
(21, 0.372418)
(22, 0.372418)
(23, 0.372418)
(24, 0.372418)
(25, 0.372418)
(26, 0.372418)
(27, 0.372418)
(28, 0.372418)
(29, 0.372418)
(30, 0.372418)
};

\addplot coordinates {
(1, 0.301701)
(2, 0.301701)
(3, 0.308213)
(4, 0.309166)
(5, 0.310629)
(6, 0.324628)
(7, 0.324628)
(8, 0.335789)
(9, 0.338966)
(10, 0.346886)
(11, 0.349949)
(12, 0.350236)
(13, 0.355030)
(14, 0.358046)
(15, 0.358046)
(16, 0.360049)
(17, 0.360609)
(18, 0.363103)
(19, 0.367216)
(20, 0.368751)
(21, 0.372306)
(22, 0.376436)
(23, 0.376436)
(24, 0.376436)
(25, 0.376892)
(26, 0.380644)
(27, 0.380780)
(28, 0.385106)
(29, 0.389572)
(30, 0.390048)
};


    \legend{32-2 com busca local, 128-4 com busca local, 256-8 com busca local, 32-2 sem busca local, 128-4 sem busca local, 256-8 sem busca local}



    \end{axis}
    \end{tikzpicture}

    \end{document}

相关内容