0

I am attempting to create a TikZ graph where the vertical axis ranges from 0 to 1, and tick points at 0.33 and 0.67 with corresponding labels.

    \begin{tikzpicture}[scale=0.75]
    \begin{axis}
    [% 
    scatter/classes={%
        a={mark=square*,blue},%
        b={mark=triangle*,red},%
        c={mark=o,draw=black}},
        xlabel={$\text{Profit}$},
        ylabel={$P(\text{Profit})$},
        xtick={0, 1, 2, 3},
        xticklabels={$5 (d=1)$, $5 (d=2)$, $5 (d = 3)$, $5 (d = 4)$},x tick label style={rotate=45,anchor=east},
        ytick={0, 0.33, 0.67, 1},
        yticklabels={$0$,$1/3$, $2/3$, $1$}]
    \addplot[scatter,only marks,%
        scatter src=explicit symbolic]%
    table[meta=label] {
x     y      label
0      1   a     
1      1   a     
2      1   a
3      1   a     
    };
    \end{axis}
    \node[align=center,font=\bfseries, xshift=1.5em, yshift=1em] (title) 
    at (current bounding box.north)
    {$\bm{K=1}$};
\end{tikzpicture}

However, I am unsure as to why the above code in specifying the y-ticks is ignored, instead outputting the following. Namely, the blue points should be at the top of the graph, and not situated in the middle with the y-ticks absent. How should I amend the code?

enter image description here

2
  • 1
    You can set e.g. ymin=-0.1,ymax=1.1 to tell pgfplots what your desired range is.
    – user299596
    Jun 27 at 22:56
  • That did it, thanks. Jun 27 at 23:02

0

You must log in to answer this question.

Browse other questions tagged .