It's very powerful, I give them that, if you can think of a figure, it can do it. But you will probably spend an evening trying to make the labels not touch each other.
It's very powerful, I give them that, if you can think of a figure, it can do it. But you will probably spend an evening trying to make the labels not touch each other.
fig, axs = plt.subplots(ncols=2, figsize=(6, 3))
fig.suptitle('Two Made-Up Plots')
axs[0].plot(np.sinc(np.linspace(-5, 5)))
axs[1].imshow(np.random.normal(size=(10, 10)))
fig.tight_layout() # works really well here!
More here: https://matplotlib.org/stable/tutorials/intermediate/tight_l...You can also use `constrained_layout`, but in my experience it often doesn't work as well (e.g., the plots end up looking too cluttered for my taste), and also, `constrained_layout` can be noticeably slower (e.g., if you're drawing a large number of complex plots): https://matplotlib.org/stable/tutorials/intermediate/constra...
When Plotly offline version matured (circa v 4) I moved over.
Lately, I've found that matplotlib is just fine for quick exploration when combined with Copilot prompts.
Instead of spending 20 minutes staring at matplotlib documentation, I can be done in 2 minutes with a prompt or two.
# my prompt can be something like get me horizontal bar chart of columns "foo" and "bar" from current dataframe. Rotate x axis ticks 45 degrees. Add y grid every 10 values. Use log scale for y. Add arrows with values for maximum values. Use emojis for markers.
# result might require tiny bit of adjustment but will basically be there. # Full disclosure: I haven't tried the emoji prompt...
These days, rather than struggling with the mess that is Python plotting, I drop into rpy2 and make the figure in R (so much easier and unusual figure types are covered).
This probably looks like grumbling or something, but it is sincerely a great help.
the real "competition" is, I believe, d3.js and visualization grammars built on top of SVG and d3 (vega, vega-lite) that allow amazing interactivity for non-technical users.
you can integrate matplotlib nicely with, e.g., django to deliver server-rendered visuals, but its all static. this relegates matplotlib to exploratory modes (within an IDE or notebook) and production pipelines.
this all might change with pyscript and a browser backend, remains to be seen.