Live data from Hacker News

Creating publication-quality figures with Matplotlib

github.com

11–15 of 15 posts

Re: Creating publication-quality figures with Matplotlib

#11

They look good, but the amount of code is staggering!

This rings a huge bell^H^H^Hgong to me. MPL is relatively complete, but it has been one of the worst libraries for plotting that I've ever used. You can make nice plots with it, but you can do the same using most of the other libraries as well. It's terribly inefficient when used with the OO interface, which is allegedly the "way to go". But in reality it's so verbose, that almost everybody is using the pylab wrapper…

What do you mean you can't change the line type? http://matplotlib.org/api/lines_api.html#matplotlib.lines.Li...

Other than that, I'd have to agree with you that mpl has quite a clunky interface. It can produce nice figures, but that generally requires lots of code to manually fine-tune the appearance of the figure.

Re: Creating publication-quality figures with Matplotlib

#12
post #11

Earlier quoted context omitted.

This rings a huge bell^H^H^Hgong to me. MPL is relatively complete, but it has been one of the worst libraries for plotting that I've ever used. You can make nice plots with it, but you can do the same using most of the other libraries as well. It's terribly inefficient when used with the OO interface, which is allegedly the "way to go". But in reality it's so verbose, that almost everybody is using the pylab wrapper…

What do you mean you can't change the line type? http://matplotlib.org/api/lines_api.html#matplotlib.lines.Li... Other than that, I'd have to agree with you that mpl has quite a clunky interface. It can produce nice figures, but that generally requires lots of code to manually fine-tune the appearance of the figure.

Maybe it wasn't clear enough, but you cannot change linetypes of the series when using "seaborn". You could manually iterate through the generated artists and change those after the fact, but this largely removes any benefit of using their style interface.

Re: Creating publication-quality figures with Matplotlib

#13
post #4

I use Matplotlib for my publications written in latex. Matplotlib can also render via a latex backend, which gives you then matching fonts and symbols in the text and figure by using something as simple as: rc('text', usetex=True) matplotlib.rcParams['text.latex.preamble'] = ['\\usepackage{siunitx}'] Here is an example from my own publication, with 100% Matplotlib and latex: http://scitation.aip.org/content/aip/journ…

Another way to do this (if one wants all plots to be rendered throug LaTeX) is to modifiy the matplotlibrc to include:

  text.usetex         : True
And something similar for the text.latex.preamble section.

Re: Creating publication-quality figures with Matplotlib

#14
post #10

Seaborn is now my goto plotting library for python. It's built on Matplotlib but with default themes and colour palettes that are much better out of the box and rarely require modification. It plays nicely with pandas dataframes and has a number of useful built-in plots. http://stanford.edu/~mwaskom/software/seaborn/ http://stanford.edu/~mwaskom/software/seaborn/tutorial/plott... http://stanford.edu/~mwaskom/software…

It is still a bit buggy, but I use it as well. Sometimes even only to get nice colours for Matplotlib (or more often: Pandas). Plus, there are many plots (e.g. heatmap, jointplot) that are practical and frequent, yet it would take a lot of lines of Matplotlib.

Re: Creating publication-quality figures with Matplotlib

#15
Matplotlib is awesome. I just wish the API was cleaner:

  figure.set_frameon()
  axis.set_frame_on()

  pyplot.xlim()
  axis.set_xlim()
This is really pain to deal with when you convert a plot into a subplot and have to switch to the different axis API. Some of this is damage from copying Matlab's legacy but it could use a polish. If you don't use an editor with IntelliSense you have to constantly look up methods in the docs to find the right spelling.
Post reply on HN