Function Repository Resource:

FoodCompassPlot

Source Notebook

Create a nutrition plot for a given food

Contributed by: Thomas Peters

ResourceFunction["FoodCompassPlot"][food]

returns a plot of the nutrition of the Entity food compared to the recommended daily values.

Details

ResourceFunction["FoodCompassPlot"] will work with EntityInstance as well as EntityGroup inputs.

Examples

Basic Examples (2) 

Creates a plot showing the nutrition of an orange:

In[1]:=
ResourceFunction["FoodCompassPlot"][Interpreter["Food"]["orange"]]
Out[1]=

Create a plot for fast food chicken wings:

In[2]:=
ResourceFunction["FoodCompassPlot"][
 Entity["Food", "ChickenWingFriedCoatedFromFastFood::p6n74"]]
Out[2]=

Scope (2) 

FoodCompassPlot also works with EntityInstance for more specific results:

In[3]:=
ResourceFunction["FoodCompassPlot"][
 EntityInstance[Interpreter["Food"]["orange"], Quantity[200., "Grams"]]]
Out[3]=

Multiple Entity or EntityInstance objects can be combined using EntityGroup:

In[4]:=
ResourceFunction["FoodCompassPlot"][EntityGroup[
  {
   EntityInstance[
    Entity["Food", "FoodType" -> ContainsExactly[{"Banana"}]],
    Quantity[200., "Grams"]
    ],
   EntityInstance[
    Entity["Food", "FoodType" -> ContainsExactly[{"Chocolate"}]],
    Quantity[300., "Grams"]
    ]
   }
  ]
 ]
Out[4]=

Possible Issues (2) 

Missing is returned when the proper nutritional information does not exist:

In[5]:=
ResourceFunction["FoodCompassPlot"][
Entity["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Rice"]}], EntityProperty["Food", "AddedFoodTypes"] -> ContainsExactly[{}], EntityProperty["Food", "SourceFoodTypes"] -> Entity[
    "FoodType", "Beef"], EntityProperty["Food", "Preparation"] -> Entity[
    "FoodPreparation", "Fried"]}]]
Out[5]=

If all the nutrition is 0, FoodCompassPlot will not render properly:

In[6]:=
ResourceFunction["FoodCompassPlot"][Interpreter["Food"]["water"]]
Out[6]=

Publisher

Tommy Peters

Version History

  • 1.0.0 – 23 December 2022

Related Resources

License Information