2

Matlab gave me this code for graph. I want to remove values from axes and add only my own values, which are \pi and \sqrt{2}. How to edit this code?

\begin{tikzpicture}

\begin{axis}[%
scale only axis,width=4.48966in,height=3.54103in,
xmin=0, xmax=314.159,
ymin=0, ymax=1.5,
ztick={-1,0,1},
zticklabels={\empty},
axis on top]
\addplot [
color=black,
solid
]
coordinates{
.... 
};

\end{axis}
\end{tikzpicture}
5
  • 1
    If you mean the labels on your axes, try adding xtick={-3.14,0,3.14} and xticklabels={$-\pi$,$0$,$\pi$}. Checkout pgfplots p.224.
    – aagaard
    May 19, 2012 at 23:33
  • @Harish Kumar: No. I mean I don't want to see any values marked on axes. The only two I need are 3.14 (marked as pi) and 1.44 (marked as sqrt(2)). And these values should be at the points of ymax and xmax.
    – Pavasaris
    May 19, 2012 at 23:36
  • @aagaard: thanks for helpful hint. Problem solved.
    – Pavasaris
    May 19, 2012 at 23:50
  • 1
    I think a better solution would be to use \pgfkeys{/pgfplots/every axis/.style={xtick={-3.14,0,3.14}, xticklabels={$-\pi$,$0$,$\pi$}}} so that you don't actually need to edit the code produced by matlab, and can just include the picture directly. May 20, 2012 at 1:11
  • @aagaard Can you write up a small example such that this question is out of the unanswered list?
    – percusse
    May 20, 2012 at 16:22

1 Answer 1

5

An example which utilizes xtick and xticklabels. See in the pgfmanual p.224.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[%
    scale only axis,width=4.48966in,height=3.54103in,
    xmin=0, xmax=4,
    ymin=0, ymax=1.5,
    xtick={0,1.41,3.14},
    xticklabels={0,$\sqrt{2}$,$\pi$}, axis on top]
    \addplot[color=black,solid] coordinates{
      (0.0,0.0) (0.5,0.48) (1.00, 0.84) (1.5,1.0) (2,0.91)
      (2.5,0.6) (3.0,0.14) (3.50,-0.35)
    };
    \addplot[color=red,domain=0:pi,dashed,thick] {sin(deg(x))};
  \end{axis}
\end{tikzpicture}

\end{document}


tikzpicture of code

You must log in to answer this question.

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