
Creating publication-quality figures with Matplotlib - mandor
https://github.com/jbmouret/matplotlib_for_papers
======
sonium
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/journal/apl/104/9/10.10...](http://scitation.aip.org/content/aip/journal/apl/104/9/10.1063/1.4867908)

A clear advantage using Matplotlib is reusability as opposed to the time
needed to set the plotting parameters right for every single figure over and
over. I would really recommend this kind of workflow to anyone in academic
publishing.

~~~
yannis
Can you post a link that is not behind a $28 paywall for having to look at an
example?

------
pbsk
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/)
[http://stanford.edu/~mwaskom/software/seaborn/tutorial/plott...](http://stanford.edu/~mwaskom/software/seaborn/tutorial/plotting_distributions.html)
[http://stanford.edu/~mwaskom/software/seaborn/tutorial/times...](http://stanford.edu/~mwaskom/software/seaborn/tutorial/timeseries_plots.html)

~~~
stared
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.

------
kevin_thibedeau
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.

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

~~~
tenfingers
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 at least in parts to reduce the boilerplate you need.
Not to mention that the pylab wrapper in itself is a very crappy compromise
with a lot of state. I never used Matlab, but I certainly know that I don't
like the way it works.

Even basic stuff, like the ability to customize/cycle the color of the series
in a central place (which is key to being able to use palettes efficiently) is
not there. You need to supply color values manually!

I routinely use a lot of plotting programs, but despite its shortcomings I
keep reaching "gnuplot" very often. The syntax is arcane, but gets the job
done quickly. You can customize the plot in a few commands, and often a simple
~/.gnuplotrc with a few defaults can make the plots look _identical_ to MPL.

The "publication quality" is a red herring. What makes the plot publication
quality is not the software. As long as it renders with AA or at 300 dpi, you
can get the same output from most of the plotting packages.

Now, speaking about plotting packages, I've been using 'seaborn' a lot
recently, which helps in reducing the clutter you need around MPL.
Unfortunately, like most of the packages that just wraps core functionality,
it's sometimes impossible to customize the plots the way you need. For
example, you cannot get decent B/W plots, since you cannot customize the line
types (again, missing functionality from MPL which should be core). The same
on gnuplot takes 2 seconds. You would think that plotting in B/W should be
common, given that often you need to pay extra to publish color figures, and
this clashes a bit in the "publication quality" issue, which seaborn also
claims.

A package in pythonland that shows promise is yhat/ggplot, which is a copy of
the former package in R. I'm not superfond of the ggplot way of plotting: it
requires a lot of data alignment before you can use it effectively (contrast
this to seaborn/gnuplot, which also lets you plot any series without much
fuss). But it's already way better than plain MPL.

Unfortunately mastering a plotting package takes a long time. I'm curious
about impressions about alternative plotting packages to python, geared at
_figures_ (so excluding interactive/javascript/web based plotting backends).

~~~
auxym
What do you mean you can't change the line type?
[http://matplotlib.org/api/lines_api.html#matplotlib.lines.Li...](http://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D.set_linestyle)

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.

~~~
tenfingers
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.

------
emp_zealoth
Will there be any way to integrate it with Octave?

