Function Repository Resource:

FattyAcidsExplorer

Source Notebook

Explore the fatty acid composition of cooking fats and oils

Contributed by: Gay Wilson

ResourceFunction["FattyAcidsExplorer"][]

creates an interactive BarChart for exploring the fatty acid content in 18 cooking fats and oils.

ResourceFunction["FattyAcidsExplorer"][format]

returns the fatty acid content for all oil types in the data in the specified format.

ResourceFunction["FattyAcidsExplorer"][oil type]

returns a full fatty acid profile for the specified oiltype.

ResourceFunction["FattyAcidsExplorer"][oil type,category]

returns the fatty acid content for the specified category of the specified oiltype.

Details

Fatty acids are long hydrocarbon chains with a carboxylic acid at one end. Monounsaturated fatty acids (MUFAs) have one carbon-carbon double bond. Polyunsaturated fatty acids (PUFAs) have two or more carbon-carbon double bonds. Saturated fatty acids have no carbon-carbon double bonds because the molecules are fully saturated with hydrogen atoms.
By default, a Manipulate allowing the user to select the oil type and category of fatty acid is returned in a BarChart.
Each bar in the chart represents the amount in grams of the fatty acid relative to 1 gram of the selected cooking fat or oil (g/g). Hover over a bar to view the numeric value.
ResourceFunction["FattyAcidsExplorer"] supports the following format values:
"Dataset"returns a Dataset of the fatty acids content in 18 cooking fats and oils
"Tabular"returns the oil types and associated fatty acids content as a Tabular object
"Data"returns associations of the complete data, including food entities and full property names
ResourceFunction["FattyAcidsExplorer"] supports lookup by text string of a specified fat or oil type. A second, optional argument of the fatty acid category also is supported.
Oil type and fatty acid category lookups are case-insensitive.

Examples

Basic Examples (3) 

Display the interactive BarChart to select an oil type and fatty acid type:

In[1]:=
ResourceFunction["FattyAcidsExplorer"][]
Out[1]=

Get the full fatty acid profile for a single fat or oil type:

In[2]:=
ResourceFunction["FattyAcidsExplorer"]["canola oil"]
Out[2]=

Get a single fatty acid category for a specified fat or oil type:

In[3]:=
ResourceFunction["FattyAcidsExplorer"]["Butter", "Saturated"]
Out[3]=

Scope (3) 

Display the categorized fatty acids data as a Dataset:

In[4]:=
ResourceFunction["FattyAcidsExplorer"]["Dataset"]
Out[4]=

Display the data as a Tabular object:

In[5]:=
ResourceFunction["FattyAcidsExplorer"]["Tabular"]
Out[5]=

Display associations of the complete data, including food entities and full property names:

In[6]:=
Short[ResourceFunction["FattyAcidsExplorer"]["Data"], 8]
Out[6]=

Applications (1) 

Sort the Tabular data according to the monounsaturated oleic acid content with SortBy, then display the oleic acid in all of the cooking fats and oils with ListPlot:

In[7]:=
tabularData = ResourceFunction["FattyAcidsExplorer"]["Tabular"];
sortedOleicAcid = SortBy[tabularData, "Oleic acid"];
ListPlot[sortedOleicAcid -> "Oleic acid", Sequence[
 Axes -> {False, True}, AxesLabel -> "g/g", Ticks -> {None, 
Range[0, 0.8, 0.1]}, PlotRange -> {0, 0.8 + 0.02}, PlotLabel -> "Oleic Acid in Cooking Fats and Oils", PlotStyle -> DarkYellow, LabelingFunction -> (sortedOleicAcid[
Part[#2, 2], "Oil type"]& )]]
Out[8]=

Possible Issues (1) 

The requested oil type or fatty acid category may not be available in the dataset:

In[9]:=
ResourceFunction["FattyAcidsExplorer"]["low-calorie oil"]
Out[9]=
In[10]:=
ResourceFunction["FattyAcidsExplorer"]["butter", "short chain"]
Out[10]=

Neat Examples (4) 

BarChart is another effective way to visualize the fatty acids data. In this case, the data is sorted according to the amount of saturated palmitic acid:

In[11]:=
tabularData = ResourceFunction["FattyAcidsExplorer"]["Tabular"];
sortedPalmiticAcid = SortBy[tabularData, "Palmitic acid"];
palmiticAcidValues = sortedPalmiticAcid[All, "Palmitic acid"];
oilTypes = sortedPalmiticAcid[All, "Oil type"];
BarChart[palmiticAcidValues, Sequence[ChartLabels -> Placed[
Map[Rotate[#, Pi/2]& , oilTypes], Below], AxesLabel -> {Automatic, "g/g"}, PlotLabel -> "Palmitic Acid in Cooking Fats and Oils"]]
Out[12]=

Use Histogram to group the values for two saturated fatty acids (palmitic acid and stearic acid) into bins and see how frequently they occur:

In[13]:=
Histogram[tabularData -> {"Palmitic acid", "Stearic acid"}, Sequence[
 5, AxesLabel -> {Automatic, "Count"}, Ticks -> {Automatic, 
Range[0, 12, 1]}, ChartLegends -> {"Palmitic acid", "Stearic acid"}]]
Out[13]=

Visualize and compare the distribution of values for the most dominant fatty acid in each category—a MUFA, a PUFA and a saturated fatty acid. SmoothHistogram replaces the discrete bins of Histogram with a continuous curve to show the shape and overlap of the distributions. The curve represents the probability density, rather than a raw count:

In[14]:=
SmoothHistogram[
 tabularData -> {"Oleic acid", "Linoleic acid", "Palmitic acid"}, Sequence[
 PlotRange -> {{0, Automatic}, All}, AxesLabel -> {Automatic, "Density"}, Filling -> Axis, PlotLegends -> {"MUFA: Oleic acid", "PUFA: Linoleic acid", "Saturated: Palmitic acid"}]]
Out[14]=

BoxWhiskerChart displays the minimum, median and maximum values for the three dominant fatty acids, as well as the interquartile range:

In[15]:=
BoxWhiskerChart[
 tabularData -> {"Oleic acid", "Linoleic acid", "Palmitic acid"}, Sequence[
 PlotRange -> {{0, Automatic}, All}, Ticks -> {None, 
Range[0, 0.8, 0.1]}, ChartLabels -> {"Oleic acid", "Linoleic acid", "Palmitic acid"}, ChartStyle -> {DarkBlue, DarkYellow, DarkGreen}, Frame -> False, Axes -> True, AxesLabel -> {Automatic, "g/g"}, AxesOrigin -> {Automatic, 0}]]
Out[15]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.1.0 – 01 May 2026
  • 1.0.0 – 25 March 2026

Related Resources

License Information