What is the difference between them? Which one is better for what purposes?

If im writing a paper in mathematical analysis, which should i use?

  • 2
    Both commands can create axes... But the axis environment is more automated and possibly you will have to write less code to have ticks and labels and legends etc. personally I prefer to use the basic tikz commands like \draw in order to have full flexibility in my generated output and because learning to use axis environment needs more memory about its options and the way they should be used to give a non so standard output. In short, axis will give automated axes and labels and legends etc... and \draw will need much more commands for a simple graph.. Adjusting could inverse this – koleygr Mar 9 at 17:53
  • If you are willing to read the pgf manual for as many adjustments (on the axes, the labels, the marks the legends etc) as possible and could remember all these, axis environment would save you from extra coding... If not, a few basic tikz commands like \draw could help you to do almost everything but usually with much more code and some (mostly in very special requests) times with less. My point of view is that keeping my memory somehow empty and available for more important for me things is preferable even if I have to code some more... Coding is fun anyway! Hope that helped. – koleygr Mar 9 at 18:04
  • Final, I have to add, that if you go for the \draw option... Check at least the \foreach command as soon as possible before really start creating axes... – koleygr Mar 9 at 18:08
  • There is no "difference" because internally axis uses \draw[->]... (unless you suppress the axis lines). Which one you should use depends on what you want to depict. If you want to draw a simple circle, an axis might be an overkill, if you want to draw a 3d plot with 3d ordering of surfaces, you may need it badly. – user121799 Mar 9 at 18:27

There is no intrinsic difference because internally axis uses \draw[->]... (unless you suppress the axis lines). Which one you should use depends on what you want to depict. Here are some thoughts:

  1. If you want to draw a simple circle, an axis might be an overkill.
  2. If you want to draw a 3d plot with 3d ordering of surfaces, you may need pgfplots badly.
  3. In general pgfplots is particularly useful if you want to plot a function that you can parametrize.
  4. On the other hand, if you want to sketch things, plain TikZ may be more straightforward. It will also compile a bit faster.
  5. There is no true distinction because pgfplots is based on TikZ. So if you start working with them, you may want to make yourself familiar with basic TikZ syntax first.
  • I didn't provided an answer and commented instead, because I don't use pgfplots often and it was somehow harder for me to give some example (2 or 3) to make clear what I meant... But during writing my comments, I was thinking that you could do what I didn't... since you are expert on both and just a copy paste/adjustment of 2,3 of your answers would make clear the differences... (+1 anyway, but if this is not a duplicate I would be glad to see more from you on this question). – koleygr Mar 9 at 18:51
  • @koleygr Thanks for the heads up! I actually do not know how to really answer this question because the answer will depend very much on the user. Without any concrete example it is very hard to give a meaningful advice, and even with it is hard because if often happens that in the very end someone decides "Oh, and now I'd like to add this thingy." which completely invalidates the choice made previously. One can also use \draw[->]... in a tree, in which case I'd most likely would recommend forest, or for true 3d stuff asymptote. – user121799 Mar 9 at 20:11
  • You are right, but your answer could be a nice demonstration without giving "your hart" to one or the other solution. (I could not do this but you can due to pgf knowledge). For example, you could give two simple plots as a first step (Let's say of f(x)=x^2, 0<x<3) with both approaches (that would show how easier pgfplots makes it) and then adjust in the same plot with each way the "ticks" (not sure about the word... the lines that shows the values on each axis), ... (nothing on x=0,small on x=0.5, big x=1, small x=1.5, big x=2, small x=2.5). [Just an example -not sure if appropriate-] – koleygr Mar 9 at 20:23
  • This question is in any case find-able from non advanced tikz and pgfplots users but from newcomers to this stuff... Sure one really simple and one just somehow more advanced example would help any newcomer to just get an idea from where to start... This is the point of such a question but without advice or plus/minus... Let them see both work. (my example may be is not appropriate but sure you can find an appropriate to demonstrate both of them working) – koleygr Mar 9 at 20:28
  • 1
    @koleygr This site is full of nice examples and the manuals are IMHO very nicely written, much nicer than any answer here could. Any attempt to beat those will IMHO be futile. There exists already a good number of tutorials. – user121799 Mar 9 at 20:28

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.