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 bar chart for exploring the fatty acid content in 17 cooking fats and oils.

ResourceFunction["FattyAcidsExplorer"][format]

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

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 containing 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 17 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

Examples

Basic Examples (1) 

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

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

Scope (3) 

Display the categorized fatty acids data as a Dataset:

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

Display the data as a Tabular object:

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

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

In[4]:=
ResourceFunction["FattyAcidsExplorer"]["Data"] // Short[#, 3] &
Out[4]=

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[5]:=
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[6]=

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[7]:=
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[8]=

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[9]:=
Histogram[tabularData -> {"Palmitic acid", "Stearic acid"}, Sequence[
 AxesLabel -> {Automatic, "Count"}, Ticks -> {None, 
Range[0, 11, 1]}, ChartLegends -> {"Palmitic acid", "Stearic acid"}]]
Out[9]=

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[10]:=
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[10]=

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

In[11]:=
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[11]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 25 March 2026

Related Resources

License Information