Histograms

Given a particular column from a csv data source, figio can create a frequency count histogram. We illustrate this functionality on a large data set called sr2s10.csv (5.4 MB) and sr2s50.csv (11 MB). To reproduce this example, download the two data sets and place them in a local ~/temp folder.

For concreteness in the following discussion, the first 10 rows of sr2s10.csv appear below:

  maximum edge ratio,    minimum scaled jacobian,               maximum skew,                     volume
          1.000000e0,                6.663165e-1,                2.872659e-1,                4.368155e-2
          1.193120e0,                6.478237e-1,                4.187394e-1,                8.360088e-2
          1.247881e0,                6.474025e-1,                4.065007e-1,                9.447332e-2
          1.214427e0,                6.549605e-1,                3.901043e-1,                8.909662e-2
          1.179123e0,                6.668604e-1,                3.859307e-1,                8.359763e-2
          1.171296e0,                6.702009e-1,                3.868204e-1,                8.222564e-2
          1.175480e0,                6.695364e-1,                3.874507e-1,                8.270613e-2
          1.178150e0,                6.694542e-1,                3.873941e-1,                8.308343e-2

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

::::::::::::::
histogram.yml
::::::::::::::
s10_aspect:
  type: hmodel
  folder: ~/temp
  file: sr2s10.csv
  skip_rows: 1
  ycolumn: 0
  plot_kwargs:
    alpha: 0.7
    color: blue
    label: sr2s10
    linewidth: 2.0
s10_msj:
  type: hmodel
  folder: ~/temp
  file: sr2s10.csv
  skip_rows: 1
  ycolumn: 1
  plot_kwargs:
    alpha: 0.7
    color: blue
    label: sr2s10
    linewidth: 2.0
s10_skew:
  type: hmodel
  folder: ~/temp
  file: sr2s10.csv
  skip_rows: 1
  ycolumn: 2
  plot_kwargs:
    alpha: 0.7
    color: blue
    label: sr2s10
    linewidth: 2.0
s10_vol:
  type: hmodel
  folder: ~/temp
  file: sr2s10.csv
  skip_rows: 1
  ycolumn: 3
  plot_kwargs:
    alpha: 0.7
    color: blue
    label: sr2s10
    linewidth: 2.0
s50_aspect:
  type: hmodel
  folder: ~/temp
  file: sr2s50.csv
  skip_rows: 1
  ycolumn: 0
  plot_kwargs:
    alpha: 0.7
    color: orange
    label: sr2s50
    linewidth: 2.0
s50_msj:
  type: hmodel
  folder: ~/temp
  file: sr2s50.csv
  skip_rows: 1
  ycolumn: 1
  plot_kwargs:
    alpha: 0.7
    color: orange
    label: sr2s50
    linewidth: 2.0
s50_skew:
  type: hmodel
  folder: ~/temp
  file: sr2s50.csv
  skip_rows: 1
  ycolumn: 2
  plot_kwargs:
    alpha: 0.7
    color: orange
    label: sr2s50
    linewidth: 2.0
s50_vol:
  type: hmodel
  folder: ~/temp
  file: sr2s50.csv
  skip_rows: 1
  ycolumn: 3
  plot_kwargs:
    alpha: 0.7
    color: orange
    label: sr2s50
    linewidth: 2.0
figure_aspect:
  type: hview
  models: [s10_aspect, s50_aspect]
  folder: ./  # the current directory
  file: hist_sr2sx_aspect.svg
  size: [8.0, 6.0]
  title: Maximum Aspect Ratio
  xlabel: Maximum Aspect Ratio
  ylabel: Frequency
  details: true
  display: true
  dpi: 100
  latex: false
  save: true
figure_msj:
  type: hview
  models: [s10_msj, s50_msj]
  folder: ./  # the current directory
  file: hist_sr2sx_msj.svg
  size: [8.0, 6.0]
  title: Minimum Scaled Jacobian
  xlabel: Minimum Scaled Jacobian
  ylabel: Frequency
  details: true
  display: true
  dpi: 100
  latex: false
  save: true
figure_skew:
  type: hview
  models: [s10_skew, s50_skew]
  folder: ./  # the current directory
  file: hist_sr2sx_skew.svg
  size: [8.0, 6.0]
  title: Maximum Skew
  xlabel: Maximum Skew
  ylabel: Frequency
  details: true
  display: true
  dpi: 100
  latex: false
  save: true
figure_vol:
  type: hview
  models: [s10_vol, s50_vol]
  folder: ./  # the current directory
  file: hist_sr2sx_vol.svg
  size: [8.0, 6.0]
  title: Element Volume
  xlabel: Element Volume
  ylabel: Frequency
  details: true
  display: true
  dpi: 100
  latex: false
  save: true

Run figio on the input file to produce the figures:

figio histogram.yml

Processing file: histogram.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.
====================================
Histogram default plot_kwargs: {'alpha': 1.0, 'bins': 20, 'color': 'black', 'histtype': 'step', 'label': '', 'linewidth': 1.0, 'log': True}
Histogram updated plot_kwargs: {'alpha': 0.7, 'bins': 20, 'color': 'blue', 'histtype': 'step', 'label': 'sr2s10', 'linewidth': 2.0, 'log': True}
Valid: Validated data: {'alpha': 0.7, 'bins': 20, 'color': 'blue', 'histtype': 'step', 'label': 'sr2s10', 'linewidth': 2.0, 'log': True}

The following figures appears: