For the folks who don't like the default style of matplotlib, fonts, colors etc... I made a stylesheet for my plots based on tailwindcss which you can use: https://www.bruderer.ai/blog/matplotlib
I really like the book's subchapter on colours, wish it was even more elaborated on. Colours are one of the subtle things I so often find difficult to get right.
As to using matplotlib in published research: when I started out as an undergrad, everybody in the research team used OriginLab for plotting -- my impression of it then was pretty good. At some point, I started using matplotlib + Latex + science plots and it caught on, mostly because there's no need to shift all the data around to a separate programme. Scienceplots package does heavy lifting with fonts and styling for specific journals, so it's just a matter of designing the right plot geometry and information density [1].
[1] an obligatory Tufte citation.
My weapon of choice is still R + dyplr + ggplot2 - mostly because I have been using it for so long and know it by heart.
I'd love to try something new, but don't feel the whole Python world is it. Is there any modern take - doesn't have to be production ready but should show a promising future? Anything from a more modern ecosystem, like Rust or zig, maybe?
It probably depends on your interests but I'm excited about the efforts using GPU rendering for interactivity (it's related to vispy but I forget the latest status of whether vispy is the current focus... I think the last I remember is someone was prototyping a vulkan-based system).
Love Mr. Rougier's open books. I supported this one while it was in development and I wasn't disappointment by the final product.
I've long awaited for him to finish "Python & OpenGL for Scientific Visualization" [0] but I'll take this in the mean time :P
[0] https://www.labri.fr/perso/nrougier/python-opengl/#python-op...
I second this! Nicolas and I have been working hard lately to try to advance the field of scientific visualization in Python — stay tuned!
Very nice guy too! Met him at a workshop recently and got a hardcopy of the book
Please for the love of reproducibly, interactivity, and not having 200 system dependencies use plotly instead of matplotlib.
Interactivity is not desirable in all situations. For static figures, matplotlib is still king.
Can plotly generate publication ready vector graphics with Latex texts?
plotly has had ten years to take over the world?
Maybe I can’t see the forest for the trees but is there an html version available?
As an Engineer (but in a scientific field) I just love Matplotlib. I moved a number of years ago from Matlab and even Excel (love how I still see papers with that mid grey background and full magenta on figures).
I'm a poor data analyst and programmer but have always managed to do what I need, mostly just time series and scatter plots. Sometimes a little more involved for my ability: such as a set of heat maps with common scaling and some tiles omitted...
I see some comments about the quality of the rendering and the look, but I think the default is really good. Nice proportionality of text, lineweight etc IMO.
Anyway I'll get to my point. I really can't get any value out of the Matplotlib official documentation. I'm not going to criticize it, just say that its not compatible with my brain. On this basis, good quality and accessible literature like this is very well received.
Python ^ ( matplotlib v pyqtgraph ) is my goto
Nice book. But frankly Tikz and pgfplots are better for scientific visualization, unless your plot is too complex (in which case you have to settle for a lower quality plot).
You can use matplotlib's pgf backend for direct use in latex. That said, not sure I agree that's better for scientific viz. Perhaps in the past. Also tikz/pgf is much more fiddly and has it's limitations too (imho).
How do you use those outside of Latex? Lots of figures are coming from Matlab or Python, where Latex is a non-starter. Is there a cookbook to pollinate?
You export figure in PDF or some other format.
Matplotlib is very easy to customize via “style sheets”, so you can make it match any style you want. Note that you can even turn on the “usetex” option and provide a preamble to compile all text/equations via TeX.
No doubt it’s very customizable. But the display quality seems to me not as good as even matlab. At least with defaults, which is a bit barebones. You have to work on it .
The syntax of python is also a bit verbose. Like, why do we need plt.show(), when I plot a figure obviously I want to plot it! Now I know, the point is, see matlab, gnuplot etc.
Compare with the default plot of gnuplot.
The limitation of latex is you can’t do much calculation with data, and memory usage.
Don’t get me wrong, I still sometimes go to python for plotting. But it’s general purpose programming language, and for specific applications there are custom tools.
I often use Matplotlib within a GUI. It's convenient to be able to defer the display of a plot until it's fully built, for instance if the plot is displaying data in a live update mode.
> The syntax of python is also a bit verbose. Like, why do we need plt.show(), when I plot a figure obviously I want to plot it!
That is kind of annoying. Fortunately, it's easy to turn that off by activating "interactive mode", in which figures automatically appear when you use a plotting command. You can do this via "plt.ion()", or have it set automatically with
interactive : True
in your .matplotlibrc file.Just keep in mind that when you do this, most plots will by default reuse the existing frame without clearing it. So you need to manually call plt.figure() more often (which in my opinion is more logical than plt.show).
There’s also a change in semantics regarding whether the script “hangs” until the user closes the plot window, if I recall correctly.
Don’t get me wrong either – I personally prefer Gnuplot by quite a margin, Matplotlib is indeed too verbose. These days I use Matplotlib more mainly because I use Python more.
I’m just saying that it doesn’t take too much configuration to make publication-quality plots in Matplotlib either, by e.g. enabling the TeX integration and setting up a reusable stylesheet file. The style sheet format is actually very reasonable, and several examples ship with Matplotlib. There’s also the Seaborn package if you want some nicer default stylesheets.
(Side note, the same goes for Gnuplot… As shown by e.g. gnuplotting.org you can definitely create publication-quality plots there as well.)
TikZ has a steep learning curve and felt so convoluted when I tried to use it.
Great use case for llms?
I would actually be very surprised if that is true. tikz is one of those examples (like e.g. M4 macros or assembly code or OpenSCAD) where producing working code requires significant mental arithmetic. Most skilled humans need to write down intermediate calculations on a piece of paper.
If you don't believe me, look at the "tikz unicorn" of GPT4 demo fame. Then try to replicate that with the currently available "degraded because of safety" GPT4 versions. Then ask yourself how on Earth you could use that to produce publication quality graphics.
I tried the "Draw a unicorn in TiKZ" in chatGPT now, and it actually looks even better than in that paper, and the code is very clean too. Not surprising as the quality of outputs from chatbots have steadily improved in the ~17 months since.