Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm not so familiar with tikz plot. The plot looks actually like it should, but I would like to change the last position value 300 to n in the plot. Is this possible ?

enter image description here

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
% for graphs
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{calc}
\def\layersep{2.5cm}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}


\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel=No. of Neihbours,
            ylabel=MAE
            ]   
        \addplot plot coordinates {
                (1,     0.753804)
                (10,    0.759822)
                (25,    0.745213)
                (50,    0.741495)
                (75,    0.743365)
                (100,   0.746219)
                (175,   0.755337)
                (200,   0.758157)
                (300,   0.825300)
        };  

        \legend{$fullcos$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}

        \end{axis}
    \end{tikzpicture}
\end{document}
share|improve this question
    
Hi superbly, please could you wrap your code into a minimal working example (MWE), starting with \documentclass. It makes it easier for me to reproduce your situation on my machine. –  John Wickerson May 11 '13 at 20:13
1  
You can use xticklabels={<list of values>}, as in \begin{axis}[ xlabel=No. of Neighbours, ylabel=RSME, xticklabels={0,0,50,100,150,200,250,n}, ] –  Gonzalo Medina May 11 '13 at 20:32
    
I changed it to a full document. hope it helps. –  superbly May 11 '13 at 20:33
    
Hi Gonzalo Medina. That was it. Thank you very much. If you make an answer, I will accept it. –  superbly May 11 '13 at 20:35
    
@superbly answer added. –  Gonzalo Medina May 11 '13 at 20:41
show 2 more comments

1 Answer

up vote 3 down vote accepted

One possibility would be to use xticklabels={<list of values>}:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

 \begin{tikzpicture}
    \begin{axis}[
        xlabel=No. of Neighbours,
        ylabel=RSME,
        xticklabels={0,0,50,100,150,200,250,n},
        ]   
    \addplot plot coordinates {
            (1,     1.040923)
            (10,    1.015503)
            (25,    0.947140)
            (50,    0.923818)
            (75,    0.922332)
            (100,   0.925733)
            (175,   0.941590)
            (200,   0.946928)
            (300,   1.064557)
    };  
    \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

If the list of x labels is too long, the above solution might be cumbersome; here's another approach, allowing to change only the last label, without modifying the previous values:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

 \begin{tikzpicture}

    \begin{axis}[
        xlabel=No. of Neighbours,
        ylabel=RSME,
       every x tick label/.append style={alias=ultick},
       extra description/.append code={
            \fill [white] (ultick.north west) ++(0pt,-2\pgflinewidth) rectangle (ultick.south east);         
            \node [anchor=south] at (ultick.south) {n};}        ]   
    \addplot plot coordinates {
            (1,     1.040923)
            (10,    1.015503)
            (25,    0.947140)
            (50,    0.923818)
            (75,    0.922332)
            (100,   0.925733)
            (175,   0.941590)
            (200,   0.946928)
            (300,   1.064557)
    };  
    \legend{$d=2$\\$d=3$\\$d=4$\\$d=5$\\$d=6$\\}
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.