3

I am trying to plot a graph with the the following x-values:

0.01, 0.05, 0.1, 0.2, 0.3, 0.5, 0.6, 0.7, 0.8, and 0.9

When I set them to my xtick values, the numbers get pushed to the left, since they grow at different rates. I'm wondering if there's a way to have the values align to the x-axis properly.

This is how it looks, and my code follows:

enter image description here

\begin{tikzpicture}

\begin{axis}[
    title={Throughput vs. Arrival Rate (N = 10)},
    xlabel={$\lambda$ (Arrival Rate)},
    ylabel={Throughput},
    xmin=0.01, xmax=0.9,
    ymin=0, ymax=10,
    xtick={0.01,0.05,0.1,0.2,0.3,0.5,0.6,0.7,0.8,0.9},
    ytick={0,1,2,3,4,5,6,7,8,9,10},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]

% Simulated
\addplot[
    color=blue,
    mark=square,
    line width = 1.2pt,
    ]
    coordinates {
    (0.01,0.111)(0.05,0.0833)(0.1,0.267)(0.2,0.672)(0.3,1.027)(0.5, 3.2)(0.6, 8.1)(0.7,3.2)(0.8, 0)(0.9,0)
    };


\end{axis}
\end{tikzpicture}
3
  • 2
    I see the ticks properly spaced, just overlapped --- if the axis is linear, then it is linear --- and 0.01 is nearer to 0.05 than 0.3 to 0.5, full stop. I would just delete the line xticks. But maybe what you want was a symbolic axis, so @torbjørn-t answer is the correct one.
    – Rmano
    Commented Mar 12, 2016 at 22:26
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Commented Mar 12, 2016 at 22:56
  • Just looking at your labels, are you sure this shouldn't be a histogram (more usually plotted in bar chart format)?
    – Aesin
    Commented Mar 13, 2016 at 0:32

1 Answer 1

5

I don't really understand what you mean by "properly" here, if you want the ticks to be evenly spaced, use symbolic x coords:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    title={Throughput vs. Arrival Rate (N = 10)},
    xlabel={$\lambda$ (Arrival Rate)},
    ylabel={Throughput},
    xmin=0.01, xmax=0.9,
    ymin=0, ymax=10,
    symbolic x coords={0.01,0.05,0.1,0.2,0.3,0.5,0.6,0.7,0.8,0.9},
    xtick=data,
    ytick={0,1,2,3,4,5,6,7,8,9,10},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]

% Simulated
\addplot[
    color=blue,
    mark=square,
    line width = 1.2pt,
    ]
    coordinates {
    (0.01,0.111)(0.05,0.0833)(0.1,0.267)(0.2,0.672)(0.3,1.027)(0.5, 3.2)(0.6, 8.1)(0.7,3.2)(0.8, 0)(0.9,0)
    };
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • If I misunderstood you, I'll just remove this answer. Commented Mar 12, 2016 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .