Introduction

figio is Python application that uses declarative yml input file recipes to produce high quality matplotlib and figures.

The following figure types are currently supported:

  • (x, y) data (or, equivalently, time series data), and
  • histogram data.

Installation

Use of a virtual environment is recommended but not necessary.

python -m venv .venv

# Activate the venv with one of the following:
source .venv/bin/activate       # for bash shell
source .venv/bin/activate.csh   # for c shell
source .venv/bin/activate.fish  # for fish shell
.\.venv\Scripts\activate        # for powershell

Install figio from the Python Package Index (PyPI).

pip install figio

Getting Started

Tabular data is used as the data source of figio figures. Let's get started with a tabular data for the inflation rate, measured on the first day or each year. The tabular data, inflation.csv, comes from the Federal Reserve Bank of St. Louis.

::::::::::::::
inflation.csv
::::::::::::::
observation_date,FPCPITOTLZGUSA
1960,1.457975986277910
1961,1.070724147647240
1962,1.198773348201860
1963,1.239669421487530
1964,1.278911564625910
1965,1.585169263836620
1966,3.015075376884400
1967,2.772785622593090
1968,4.271796152885370
1969,5.462386200287450
1970,5.838255338482510
1971,4.292766688130510
1972,3.272278246552830
1973,6.177760063770380
1974,11.054804804804800
1975,9.143146864965351
1976,5.744812635490850
1977,6.501683994728400
1978,7.630963838856060
1979,11.254471129279500
1980,13.549201974968399
1981,10.334715340277100
1982,6.131427000274930
1983,3.212435233160650
1984,4.300535475234290
1985,3.545644152093650
1986,1.898047722342760
1987,3.664563217516900
1988,4.077741107444130
1989,4.827003030089440
1990,5.397956439903250
1991,4.234963964538490
1992,3.028819678149690
1993,2.951656966385590
1994,2.607441592154530
1995,2.805419688536620
1996,2.931204199934410
1997,2.337689937307350
1998,1.552279098743640
1999,2.188027196973580
2000,3.376857271499290
2001,2.826171118854070
2002,1.586031626506010
2003,2.270094973361150
2004,2.677236693091720
2005,3.392746845495500
2006,3.225944100704040
2007,2.852672481501380
2008,3.839100296651000
2009,-0.355546266299747
2010,1.640043442389900
2011,3.156841568622000
2012,2.069337265260670
2013,1.464832655627170
2014,1.622222977408170
2015,0.118627135552451
2016,1.261583205705360
2017,2.130110003659610
2018,2.442583296928170
2019,1.812210075260210
2020,1.233584396306290
2021,4.697858863637420
2022,8.002799820521210
2023,4.116338383744880

To plot this data, we create a yml input file called inflation.yml.

::::::::::::::
inflation.yml
::::::::::::::
inflation-data:
  type: xymodel
  folder: ./  # the current directory
  file: inflation.csv
  skip_rows: 1
  plot_kwargs:
    label: inflation rate
    linestyle: "-"  # solid line
    linewidth: 1.0
    marker: "."  # point marker
  ycolumn: 1
inflation-figure:
  type: xyview
  folder: ./  # the current directory
  file: inflation.svg  # the output file
  size: [ 8.0, 6.0 ]
  title: Inflation, consumer prices for the United States (FPCPITOTLZGUSA)
  xlabel: year
  ylabel: inflation rate (%)
  details: false
  display: true
  dpi: 100
  latex: false
  serialize: true

Run figio on the input file to produce the figure:

figio inflation.yml

Processing file: inflation.yml
====================================
Information
For (x, y) data and time series data:
  type: xymodel items associate with type: xyview items.
For histogram data:
  type: hmodel items associate with type: hview items.
====================================
Finished XYViewBase constructor.
Creating view with guid = "inflation-figure"
  Adding all models to current view.
  Figure dpi set to 100
  Figure size set to [8.0, 6.0] inches.
  Serialized view to: inflation.svg
====================================
End of figio execution.

The following figure appears:

Congratulations! You just make your first figio figure.