Function Repository Resource:

GraphicsOptionQ

Source Notebook

Test if an expression is a graphics option

Contributed by: Enrique Zeleny

ResourceFunction["GraphicsOptionQ"][expr]

returns True if expr is a graphics option, and False otherwise.

Details

The set of options is taken to be the options of all plot and plot 3D functions and include options for Graphics, Graphics3D and GeoGraphics.
ResourceFunction["GraphicsOptionQ"] works for 2D and 3D graphics options.

Examples

Basic Examples (3) 

An option considered as a graphics option:

In[1]:=
ResourceFunction["GraphicsOptionQ"][Ticks -> None]
Out[1]=
Image

An option not considered as a graphics option:

In[2]:=
ResourceFunction["GraphicsOptionQ"][GeoArraySize -> Automatic]
Out[2]=
Image

A surface:

In[3]:=
gr = Plot3D[Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}, NormalsFunction -> Automatic, Mesh -> None]
Out[3]=
Image

Extract graphics options:

In[4]:=
Cases[gr, _?ResourceFunction["GraphicsOptionQ"], 3] /. (vn : VertexNormals -> d_) :> Iconize[vn] // Union
Out[4]=
Image

Remove graphics options:

In[5]:=
DeleteCases[gr, _?ResourceFunction["GraphicsOptionQ"] , \[Infinity]]
Out[5]=
Image

An anatomy plot:

In[6]:=
rh = AnatomyPlot3D[{Entity["AnatomicalStructure", "RightHand"]}]
Out[6]=
Image

Anatomy plots may contain a lot of options at different levels:

In[7]:=
Table[Count[
  Level[rh, {n}], _?ResourceFunction["GraphicsOptionQ"], {1}], {n, Depth[rh]}]
Out[7]=
Image

Not all rules are graphics options:

In[8]:=
Table[Count[Level[rh, {n}], _Rule, {1}], {n, Depth[rh]}]
Out[8]=
Image

Properties and Relations (3) 

Some symbols have options in common with graphics options:

In[9]:=
Cases[Options[Style], _?ResourceFunction["GraphicsOptionQ"]]
Out[9]=
Image
In[10]:=
Cases[Options[Notebook], _?ResourceFunction["GraphicsOptionQ"]]
Out[10]=
Image

A bar chart:

In[11]:=
BarChart[{{1, 2, 3}, {1, 3, 2}}, ChartLayout -> "Stepped"]
Out[11]=
Image

Chart options that are graphics options too:

In[12]:=
Cases[%, (_Rule | _RuleDelayed)?ResourceFunction["GraphicsOptionQ"],
  2]
Out[12]=
Image

Chart options that are not graphics options:

In[13]:=
Cases[Options[
  BarChart], _?(! ResourceFunction["GraphicsOptionQ"][#] &)]
Out[13]=
Image

A piece of geo graphics:

In[14]:=
gg = GeoGraphics[{GeoStyling["StreetMap", EdgeForm[Red], GeoStylingImageFunction -> Sharpen], GeoDisk[Entity["Building", "WillisTower::8tzqg"], Quantity[0.5, "Miles"]]}, GeoBackground -> GeoStyling["StreetMap", GeoStylingImageFunction -> (Blur[#1, 25] &)], GeoRangePadding -> Quantity[0.2, "Miles"]]
Out[14]=
Image

Many geo graphics options are graphics options, with some exceptions:

In[15]:=
Cases[gg, _Rule?(! ResourceFunction["GraphicsOptionQ"][#1] &), {3, 5}]
Out[15]=
Image

Possible Issues (2) 

Here, Method is recognized as a graphics option:

In[16]:=
Method -> Automatic // ResourceFunction["GraphicsOptionQ"]
Out[16]=
Image

But can be an option of many other symbols:

In[17]:=
EntityClass["WolframLanguageSymbol", "OptionNames" -> ContainsAll[{"Method"}]] // EntityList // Length
Out[17]=
Image

Publisher

Enrique Zeleny

Version History

  • 1.0.0 – 16 March 2021

Related Resources

License Information