更改轴条形图

更改轴条形图

我想重新创造这个图表,但我的价值观是水平的,而不是垂直的:

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,arrows.meta,
                backgrounds, bending,
                calc, chains,
                %decorations.pathmorphing,
                fit,
                %petri,
                positioning,
                trees,
                quotes,
                shapes.misc}

\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\usepackage{graphicx}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.geometric,intersections,calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{textcomp}
\usepackage{wrapfig}


\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
                \begin{axis}[
                      %  width=\textwidth,
                       % height=\axisdefaultheight,
                        title={x},
                        xlabel={Size$Mb$},
                        ylabel={Time $Sec$},
                        xmin=0, xmax=1010,
                        ymin=0, ymax=300,
                        xbar,
                        xtick={20,100,200,500,1000},
                        ytick={0,50,100,150,200,250,300},
                      % legend pos=north west,
                        legend style={at={(1.6,.6)},anchor=north}, % legend pos=outer north east,
                        ymajorgrids=true,
                        grid style=dashed,
                    ]    
            \addplot[
              fill= darkblue,
              color=darkblue,
            ]
            coordinates {(0,0) (5,0.2)(50,1)(100,33)(200,60)(500,137)(750,200)(1000,300)};


            \addplot[
              fill= darkblue2,
              color=darkblue2,
            ]
             coordinates {(0,0) (5,0.2)(50,1)(100,30)(200,50)(500,120)(750,180)(1000,250)};
            \legend{x,y}

           \end{axis}
    \end{tikzpicture}
         \end{document}

在此处输入图片描述

谢谢您的帮助

瓦洛克

答案1

这将绘制垂直条。

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
                \begin{axis}[
                      %  width=\textwidth,
                       % height=\axisdefaultheight,
                        title={x},
                        xlabel={Size [Mb]},
                        ylabel={Time [Sec]},
                        %xmin=0, xmax=1010,
                        ymin=0, ymax=300,
                        ybar,
                        xtick={20,100,200,500,1000},
                        ytick={0,50,100,150,200,250,300},
                      % legend pos=north west,
                        legend style={at={(1.6,.6)},anchor=north}, % legend pos=outer north east,
                        ymajorgrids=true,
                        grid style=dashed,
                    ]    
            \addplot[
              fill= darkblue,
              color=darkblue,
            ]
            coordinates {(0,0) (5,0.2)(50,1)(100,33)(200,60)(500,137)(750,200)(1000,300)};


            \addplot[
              fill= darkblue2,
              color=darkblue2,
            ]
             coordinates {(0,0) (5,0.2)(50,1)(100,30)(200,50)(500,120)(750,180)(1000,250)};
            \legend{x,y}

           \end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容