FigureFirst is a python 3.5+ library to decorate and parse SVG files so they can serve as layout documents for matplotlib figures. In principle FigureFirst works on python 2.7, but it is not officially supported.
If you use FigureFirst, please cite the above paper to help others find FigureFirst.
figurefirst
using pippip install figurefirst
figurefirst
inkscape extensionsThis package includes a console script, figurefirst_ext
to install inkscape extensions.
It tries to infer the default installation path for your OS (do figurefirst_ext --help
to see what they are),
or you can pass a path in manually, e.g..
figurefirst_ext ~/.config/inkscape/extensions
This defaults to installing extensions for inkscape 1.0. If need support for older version of Inkscape (<1.0) add --inkscape_major_version 0
to the above command.
See http://flyranch.github.io/figurefirst/ for more detail, or follow the tutorial notebook: https://github.com/FlyRanch/figurefirst/blob/master/examples/tutorial/tutorial.ipynb
extensions > figurefirst > tagaxis
, e.g. A
or B
ctrl-g
), tag the group using extensions > figurefirst > tagfigure
, e.g. fig1
fifi_template.svg
import figurefirst as fifi
layout = fifi.svg_to_axes.FigureLayout('fifi_template.svg', autogenlayers=True, make_mplfigures=True, hide_layers=[])
ax = layout.axes[('fig1', 'B')]
fifi.mpl_functions.adjust_spines(ax, ['left', 'bottom'])
fifi.mpl_functions.set_fontsize(ax, 6)
layout.append_figure_to_layer(layout.figures['fig1'], 'fig1', cleartarget=True)
layout.write_svg('fifi_template.svg')
. Use a new name if you wish not to overwrite the template. from IPython.display import display,SVG
display(SVG('fifi_template.svg'))
import cairosvg
cairosvg.svg2pdf(url='fifi_template.svg', write_to='fifi_template.pdf')
FigureFirst is developed and tested with Inkscape. Some versions and settings of Inkscape are very slow, try using inkcsape 1.0. For legacy versions of Inkscape specifying the Inkscape major version as 0 in the install script. See installation above.
You may find issues with with plugins for Inkscape > 1.0. You can install Inkscape 1.0 via the following link: Inkscape 1.0
We welcome pull requests to fix compatibility with more recent version of Inkscape!
Try increasing the Rendering Tile Multiplier:
Edit > Preference > Rending
Rendering Tile Multiplier = 50
Restart Inkscapepytest
--keep_files
optiontox
How can I control the order of axes that are overlapping? To put axis 'a' on top of axis 'b', when both are in the same group 'fig':
layout = fifi.svg_to_axes.FigureLayout('fifi_axis_order.svg', autogenlayers=True, make_mplfigures=False)
layout.make_mplfigures(axes_order={'fig': ['a', 'b']})
After plotting, inkscape is very slow (because there are lots of points/lines). Rasterize using ax.set_rasterization_zorder(ZORDER)
see https://matplotlib.org/3.1.3/gallery/misc/rasterization_demo.html