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]=

An option not considered as a graphics option:

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

A surface:

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

Extract graphics options:

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

Remove graphics options:

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

An anatomy plot:

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

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]=

Not all rules are graphics options:

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

Properties and Relations (3) 

Some symbols have options in common with graphics options:

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

A bar chart:

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

Chart options that are graphics options too:

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

Chart options that are not graphics options:

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

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]=

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

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

Possible Issues (2) 

Here, Method is recognized as a graphics option:

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

But can be an option of many other symbols:

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

Publisher

Enrique Zeleny

Version History

  • 1.0.0 – 16 March 2021

Related Resources

License Information