s_haskey
s_haskey

Reputation: 539

Matplotlib figure changes for publication after making the figure

I have been running into the problem of generating publication 'perfect' images in Matplotlib (i.e changing the fontsize, marker size, figuresize, number of ticks etc...).

Essentially, I want to do what is described here: http://www.scipy.org/Cookbook/Matplotlib/LaTeX_Examples except after the figure has already been made. i.e I want to make a function that accepts the Figure object, and makes all the necessary changes, some of which are available as input arguments. That way I don't have to always modify my scripts when I decide to use a figure in a paper.

Is there an efficient way to achieve this?

Note I'm usually using Ipython.

Upvotes: 5

Views: 703

Answers (2)

Saullo G. P. Castro
Saullo G. P. Castro

Reputation: 58885

Well, we are doing this all the time to create good figures. In our case we wanted something that would automatically choose the linestyle and marker because we always have to plot many lines in the same figure, and this would avoid manually specifying these things.

We programmed some functions so that at the end you need a plot.py script, which is very simple, and an input.txt with all the info. In the input file you can also use any parameter like linewidth, label, and so forth.... but by default it will follow the pre-defined order for linestyles, markers and so on.

Also, you need a good matplotlibrc file. You can have many different matplotlibrc files since the highest priority is given to the one at the local directory, as explained here. This will allow you to customize keeping your plotting code cleaner.

The functions commented above (with examples) are available in this link, maybe they can give you some insights.

They solved one problem I had with subplots, described here.

Upvotes: 3

joaquin
joaquin

Reputation: 85613

Maybe you can make use of matplotlib pickling available in vs 1.2.1.

As said in the above link:

Philip Elson added an experimental feature to make figures picklable for quick and easy short-term storage of plots. Pickle files are not designed for long term storage, are unsupported when restoring a pickle saved in another matplotlib version and are insecure when restoring a pickle from an untrusted source. Having said this, they are useful for short term storage for later modification inside matplotlib.

No personal experience, however

Upvotes: 1

Related Questions