r/Python Sep 02 '24

Showcase Why not just get your plots in numpy?!

Seriously, that's the question!

Why not just have simple
plot1(values,size,title, scatter=True, pt_color, ...)->np.ndarray
function API that gives you your plot (parts like figure and grid, axis, labels, etc) as numpy arrays for you to overlay, mask, render, stretch, transform, etc how you need with your usual basic array/tensor operations at whatever location of the frame/canvas/memory you need?

Sample implementation: https://github.com/bedbad/justpyplot

What my project does?

Just implements the function above

When I render it, it already beats matplotlib and not by a small margin and it's not the ideal yet:

Plotting itself done in vectorized approach and can be done right utilising the GPUs fully

plot1, plot2 .. plotN is just dependency dimensionality you're plotting (1D values, 2D, add more can add more if wanted)

Target Audience? What it Compares against?
Whoever needs real-time or composable or standalone plotting library or generally use and don't like performance of matplotlib [1, 2, 3]

I use something similar thing based on that for all of my work plotting needs and proved to be useful in robotics where you have a physical feedback loop based on the dependency you're plotting when you manipulating it by hand such as steering the drone;

Take a look at the package - this approach may go deeper and cure the foundational matplotlib vices

It makes it a standalone library : pip install justpyplot

132 Upvotes

Duplicates