I'm creating a several graphs with pgfplots. The problem I'm coming across is that some graphs do not have a value for the last coordinate as per the example below (and I want to keep the ticks on the x axis consistent).




  \begin{axis}[xtick={1,2,5,10,20,50,100},xticklabels={1,2,5,10,20,50,100},unbounded coords=jump,xminorticks=false,yminorticks=false]
    \addplot[smooth] coordinates {
      (1.0000000000, 1.3562500000)
      (2.0000000000, 1.2825000000)
      (5.0000000000, NaN)
      (10.0000000000, 4.2087500000)
      (20.0000000000, 10.7962500000)
      (50.0000000000, 91.7450000000)
      (100.0000000000, NaN)


which produces:

enter image description here

Is there a way to force the x axis to include the tick and label for 100? The 'unbounded coords=jump' option does not help since there are no more lines to draw.


  • 1
    You can add something like xmax=102 to the axis options. – Gonzalo Medina Aug 28 '12 at 17:20
  • I've turned my comment into an answer, but perhaps you would like to wait a little longer before accepting it to see if someone else gives a better solution. – Gonzalo Medina Aug 28 '12 at 17:41
  • 1
    You can also check the enlarge limits options in the manual. – percusse Aug 28 '12 at 17:50
  • Since you say you want the axes to be consistent between different plots, I would suggest going with Gonzalo's suggestion (and also supplying xmin=0 explicitly). – Jake Aug 28 '12 at 18:27
  • Actually I tried Gonzalo's option (xmax=100) and 'enlargelimits=true'. This gives me a consistent output with similar spacing on both sides. So far I like it. Will go ahead and accept the answer! Thanks. – nunolopes Aug 28 '12 at 18:30

You can add something like xmax=102 to the axis options.

  • I ended up using 'xmax=100,enlargelimits=true'. Works fine. Thanks. – nunolopes Aug 28 '12 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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