Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 623
s_haskey Avatar asked Oct 04 '22 23:10

s_haskey


1 Answers

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.

like image 76
Saullo G. P. Castro Avatar answered Oct 09 '22 23:10

Saullo G. P. Castro