That said I may use matplotlib much less than you do (I used it a lot when I was a student, now maybe 6 times a year).
This! My biggest gripe against Python numerical stuff was matplotlib, until I realized that it is an entirely optional component of the stack, and you can plot by other, much saner means.
If I'm using Matplotlib, I'm almost always plotting things calculated in Python, so all my data and variables are right there ready to go. I think the fine details are controllable in more programmatic ways than Gnuplot. I use other Python libraries when they're a better fit. Being Python and object oriented makes it easy to figure out how to do many things (e.g. autocomplete).
If I'm doing one-off throwaway plots, there are better and easier tools than Gnuplot: Desmos, GeoGebra.
If I'm making interactive demos, there are better tools than Gnuplot: Desmos, GeoGebra, JSXGraph, Jupyter.
If I'm plotting a function for a high-quality PDF document, TikZ gives me more control than Gnuplot, and makes it easy to make many plots with consistent (and changeable) style, though being a Latex-based tool it has limitations to go with its power. TikZ is great for diagrams too. Asymptote is more powerful than TikZ in some ways for this kind of thing, but often harder to use.
I was mainly commenting on its configurability. Gnuplot lets you (once you figure out how) control everything; for example, the exact shape of the arrowheads in a vector plot.
(The name is “gnuplot”; it’s not a GNU project.)
This of course works with other symbolic manipulation:
plot(sin(x).diff())
plot(sin(x).subs(x, x**2))My use case is not a scratch pad with one plotting window; it’s dozens of windows with regressions and stuff. Each window is a completely different context; some of them are short lived and some of them are used for weeks. Using as many notebooks is very impractical. For example, seeing where one parameter is going in one calculations is trivial and quicker than starting a notebook and setting it up. Works transparently over ssh, too.
I am more or less fluent in Matplotlib, because I work with people who use it and I need to understand whatever the students are doing (and some of them use Python and some use R, which is a whole other discussion). I just dislike it and don’t use it much for my things. Ultimately, gnuplot’s syntax for regression and complex plots is much more concise.
I any case I think it’s good intellectual hygiene to use several tools regularly, lest you end up stuck in a way of thinking, so I encourage students to try others. It’s also good to have discussions about these things that don’t end up in holy wars; we need to be curious.
import sympy
sympy.plot(sympy.sin(x))
and it says "NameError: name 'x' is not defined" from sympy import *
x = symbols('x')
plot(sin(x))
symbols is sympy.symbols.You just want to plot the sine function, but first you have to import libraries, declare symbols (with a scary correspondence between strings and variable names), and finally plot the damn function.
Edit: plus, if I'm plotting with Sympy it's almost certainly something I've calculated symbolically with Sympy, so everything is defined and ready, and it's much more elegant than switching to a separate program. For a one-off "what does function look like?" question, both these tools are far too clunky, and I'd use Desmos or GeoGebra.
Sympy is just a Python library, and one of the types it defines is symbolic maths variables, so you define Python variables just like with any other library, and then use them.
And this, my friends, is why mathematicians will never feel at home using Python+libraries. Instead of having a programming environment ideally suited to the needs of math, you need to fit your math to the Procrustean bed of Python syntax.
I'm glad I'm not alone. I was starting to feel crazy—how can something with this bad an API (Matplotlib) be this popular in the Python ecosystem which is known for its lack of verbosity and clarity? How can it be integrated with every other package instead of some sane alternative?
I tried Seaborn (a wrapper effectively), and it is way better for doing basic plots. But as soon as you get beyond that you're back in arcane Matplotlib territory. The best thing I could have done would have been to ignore its integrations and start with a better plotting API to begin with. The little bit of extra integration effort would have been worth avoiding Matplotlib. And there are several alternatives in the Python landscape.
No offense to the authors—it's clear they've done a lot of great work. But I think they got stuck with a bad API that they started with and it became so common-place that they were forced to continually be backwards compatible with something that really needed an overhaul.
I honestly moved on to gui based plotting programs like grace or veusz, there's just a button for the things you want to do
(I think matplotlib has an openGL backend that slightly improves but doesn't fix the issues with matplotlibs handling of large datasets)
Once the pipeline is set, Python is for scripts that need to be run more than about a dozen times, or need to be run on several datasets, or for things that need to be reproduced exactly (like stuff that goes into a paper). I also use it to prepare datasets from large numbers of calculations where the useful results need to be gathered from dozens/hundreds of files in a more or less complex file structure, often on different computers, with the occasional pass with some post-processing tools.
I really dislike Matplotlib, so rendering is done in something else, usually gnuplot.
That’s for my stuff (mostly atomic-scale modelling and quantum chemistry in materials science), it might be different for other use cases...