3 ms·
By which you mean these I think? 1. the pyplot API (the old one, that is designed to mimic MATLAB - it has functions like plot() and xlabel()). 2. The Axes AP
by kzrdude 3y ago
By which you mean these I think?
1. the pyplot API (the old one, that is designed to mimic MATLAB - it has functions like plot() and xlabel()).
2. The Axes API - fig, ax = plt.subplots(); then call ax.plot(), ax.set_xlabel() and so on
One should always prefer the Axes way of doing it, it's refactorable and uses less hidden global state.
- kragen 3y agogenerally when i'm using matplotlib instead of d3 it's because i'm less concerned about things like refactorability and hidden global state than about getting some data points on the screen in as few keystrokes as possible; %pylab inline and the pyplot api are far superior for that i wish the axes api didn't exist
- kzrdude 3y agoAnd when I use matplotlib it's to clean up some non-default tweaks to seaborn plots. Refactorability here means that it's easy to go from one plot into one that's split into facets (multiple subplots etc.)
- kragen 3y agotrue, the subplot api is especially painful because i have to edit each line of code i copy-paste to give it a different subplot number
- deleted 3y ago[deleted]
- mitthrowaway2 3y ago> One should always prefer the Axes way of doing it, it's refactorable and uses less hidden global state. I fully agree, but half the time you're looking up how to do something, you find methods documented using the other approach, with slightly different method names that don't even have an alias in the axes API. In fact those are usually the ones you find, because people answering SO questions seem to prefer the brevity.