-- Leo's gemini proxy

-- Connecting to shuhao.srht.site:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Quick thoughts about plotting with Python and Julia


2021-06-17


I've spent a lot of time working with the Python scientific computing stack, especially numpy, scipy, matplotlib, along with JupyterLab. This familiarity has translated in the comfort with quickly performing (simple) analysis and the ability to produce reasonably-good-looking plots. I feel productive in it, yet I found it to be deeply unsatisfying as an user. Off the top of my head, here are a few problems:


Vectorize everything is a requirement for performance to be reasonable. For example, I'm unable to write the simple version of an algorithm with a tight loop first to examine feasibility. I usually have to vectorize from the first prototype, or drop to C (or Cython), or else it will be way too slow.

Extending off the previous point: sometimes I can't even write code like a + b + c due to how big the arrays can be. This requires fancy stuff like numba, which adds more complexity.

The matplotlib API is not great in my opinion. It feels like that it originally derived from the MATLAB syntax, which inherits the state-machine-based system for plotting. This is easy to get started but gets cumbersome later. I almost always use the object-oriented API, but due to how state-machine-centric matplotlib is, the OOP API tend to be under-documented.

I'm unaware of any ways to interactively edit plots made by matplotlib. Typing things like .set_xlabel or positioning text with code is annoying, especially when the plots take a while to generate due to their complexity. Last I tried, there are serious glitches with the 3D visualization capabilities of matplotlib. I recall having transparent objects plotted in 3D space being incorrectly obscured by other objects, which made the entire visualization unusable. I've had to resort to using VTK/Paraview, which I have love/hate relationship with as well that could fill its own post one day.

Additionally, I'm torn on if I like the matplotlib syntax or not. The whole system feels to me to be very state-machine-based, which I'm not sure if it is good or bad. Maybe there are ways to innovate to make things more intuitive, modular, or something else that I can't even imagine.


I've been recently playing a bit with Julia. I've yet to grasp the language, as I continue to be confused by keywords like let, or local. I've yet to use it outside the terminal and Pluto.jl, which means I've not yet unlocked its full potential. That said, I found that plotting in Julia has been equally as unsatisfying, as none of the plotting libraries support enough of the features I want. For example, Gadfly doesn't appear to have a system for a secondary Y axis[1]. The only plotting library that does support the minimal viable feature set is PyPlot, which basically calls matplotlib from Julia.


[1] Gadfly multiple secondary axis


If I settle for PyPlot, why do I even bother with Julia if I just end up calling the exact same Python API? I don't even get any fancy interactive features comes with some of the "Julia-native" libraries. I might as well just go back to Python/Cython at this point...


I guess a good plotting library with a large set of features and flexibility is a really hard problem. I feel it may also be a really niche problem, as most of the world are generally content with the plotting systems they do have.


As a parting note, I've been thinking of Star Trek a bit over the last little while. You see a lot of articles out there talking about all the things that Star Trek envisaged that came true: tablets and voice recognition systems are usually the most prominent ones. One thing that I think everyone missed is the ability for characters in the TV shows to quickly process and visualize data, usually with voice commands. I don't see us moving towards that direction. Is something like that truly too hard? Or is it just science fantasy?


Tags: software, science, idea



Home


Comments? Email me at shuhao >at< shuhaowu <dot> com.

-- Response ended

-- Page fetched on Fri May 3 11:52:30 2024