TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


scale only axis,width=4.48966in,height=3.54103in,
xmin=0, xmax=314.159,
ymin=0, ymax=1.5,
axis on top]
\addplot [

share|improve this question
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 '12 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 '12 at 23:36
@aagaard: thanks for helpful hint. Problem solved. – Pavasaris May 19 '12 at 23:50
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. – Peter Grill May 20 '12 at 1:11
@aagaard Can you write up a small example such that this question is out of the unanswered list? – percusse May 20 '12 at 16:22
up vote 5 down vote accepted

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



    scale only axis,width=4.48966in,height=3.54103in,
    xmin=0, xmax=4,
    ymin=0, ymax=1.5,
    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))};


tikzpicture of code

share|improve this answer

Your Answer


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.