Live data from Hacker News

Matplotlib

matplotlib.org

11–20 of 44 posts

Re: Matplotlib

#11
post #4

By far my favorite feature of matplotlib is that it produces readable and accessible plots by default. Font sizes and linewidths are not too small, the default color palette is colorblind-friendly, and the default colormaps are perceptually uniform. Other software (for example Matlab and Mathematica) have absolutely terrible defaults and require a lot of fiddling to get the plots right.

IMO the font size is still too small (ditto for pretty much all stat software). But matplotlib makes it quite easy to change the default look, here is mine:

    import matplotlib
    
    theme = {'axes.grid': True,
             'grid.linestyle': '--',
             'legend.framealpha': 1,
             'legend.facecolor': 'white',
             'legend.shadow': True,
             'legend.fontsize': 14,
             'legend.title_fontsize': 16,
             'xtick.labelsize': 14,
             'ytick.labelsize': 14,
             'axes.labelsize': 16,
             'axes.titlesize': 20,
             'figure.dpi': 100}
    
    matplotlib.rcParams.update(theme)

Re: Matplotlib

#12
post #4

By far my favorite feature of matplotlib is that it produces readable and accessible plots by default. Font sizes and linewidths are not too small, the default color palette is colorblind-friendly, and the default colormaps are perceptually uniform. Other software (for example Matlab and Mathematica) have absolutely terrible defaults and require a lot of fiddling to get the plots right.

Tangential but a thing about defaults - when I was at uni, in a lot of labs we were doing data analysis and plotting in something called Origin. I absolutely loved the defaults there, to this day I can recognize if it was plotted using origin and I had visceral reaction if I'd see something done in Excel. Sane defaults are very important and I'm not sure why they are often afterthoughts

Re: Matplotlib

#15
It's a great library. I only wish that it didn't have two completely different, incompatible interfaces to muddy the documentation, examples, and SO answer threads.

Re: Matplotlib

#17

It's a great library. I only wish that it didn't have two completely different, incompatible interfaces to muddy the documentation, examples, and SO answer threads.

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.

Re: Matplotlib

#19
post #17

It's a great library. I only wish that it didn't have two completely different, incompatible interfaces to muddy the documentation, examples, and SO answer threads.

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.

generally 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

Post reply on HN