Publication-ready 3D figures from Matplotlib

Screen Shot 2014-06-27 at 9.23.25 AMI’m a big fan of scripting my plot creation. I also use python for all of my data acquisition and analysis. This naturally put me in a spot to dive into matplotlib when it came time to create figures for a paper I’m working on. It took a bit of digging, but I worked through the kinks and put together a 3D surface plot (with contours) that is PDF and publication ready. I addressed the several issues by overriding the defaults. I want to clarify that I like the defaults for on-screen display, presentations, and posters, but they weren’t quite right for a tiny two-pane figure in a two-column manuscript. Things I “fixed” include:

  • Too many ticks and labels
  • Small fonts (when reduced to publication dimensions)
  • Tick labels misaligned relative to ticks (problem seems to come from using larger fonts to fix the previous issue)
  • Odd axes label alignment, rotation, and placement
  • Busy background (removed the gray panes with gridlines)

Some of the solutions were easy, some are hackish and only one uses the lightly-documented _axinfo dict. I’ll highlight a few snippets that were useful in this process (full code linked below).
Continue reading