Skip to content

Commit 6a3892f

Browse files
authored
Define plot options (#1528)
This PR adds a comprehensive set of Graphics and Graphics3D options. This will enable renderers - both core and non-core front-ends - to implement the options without needing changes to core to pass them through from Plot[3D] to Graphics[3D] to Graphics[3D]Box. * Comprehensive set of options are added to Graphics and Graphics3D. * Corresponding symbols are added to system symbols. * A couple of test cases that were sensitive to the presence of the new options in Graphics[3D] are adjusted. This PR adds no new function beyond passing the options through. In particular, no rendering code has been touched and no new rendering function has been added.
1 parent c096a31 commit 6a3892f

File tree

6 files changed

+121
-69
lines changed

6 files changed

+121
-69
lines changed

mathics/builtin/box/graphics3d.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
RGBColor,
2121
_ColorObject,
2222
)
23-
from mathics.builtin.drawing.graphics3d import Coords3D, Graphics3DElements, Style3D
23+
from mathics.builtin.drawing.graphics3d import (
24+
Coords3D,
25+
Graphics3D,
26+
Graphics3DElements,
27+
Style3D,
28+
)
2429
from mathics.builtin.drawing.graphics_internals import (
2530
GLOBALS3D,
2631
_GraphicsElementBox,
@@ -43,6 +48,7 @@ class Graphics3DBox(GraphicsBox):
4348
</dl>
4449
"""
4550

51+
options = Graphics3D.options
4652
summary_text = "symbol used boxing Graphics3D expressions"
4753

4854
def _prepare_elements(self, elements, options, max_width=None):

mathics/builtin/drawing/drawing_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Automatic(Builtin):
3434
graphical options:
3535
3636
>> Cases[Options[Plot], HoldPattern[_ :> Automatic]]
37-
= {Background :> Automatic, Exclusions :> Automatic, ImageSize :> Automatic, MaxRecursion :> Automatic, PlotRange :> Automatic, PlotRangePadding :> Automatic}
37+
= {AxesOrigin :> Automatic, Background :> Automatic, BaselinePosition :> Automatic, ContentSelectable :> Automatic, CoordinatesToolOptions :> Automatic, Exclusions :> Automatic, FrameTicks :> Automatic, ImageSize :> Automatic, MaxRecursion :> Automatic, Method :> Automatic, PlotRange :> Automatic, PlotRangePadding :> Automatic, PlotRegion :> Automatic, PreserveImageOptions :> Automatic, Ticks :> Automatic}
3838
"""
3939

4040
summary_text = "graph option value to choose parameters automatically"

mathics/builtin/drawing/graphics3d.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,30 @@ class Graphics3D(Graphics):
110110
summary_text = "a three-dimensional graphics image wrapper"
111111
options = Graphics.options.copy()
112112
options.update(
113-
{"BoxRatios": "Automatic", "Lighting": "Automatic", "ViewPoint": "{1.3,-2.4,2}"}
113+
{
114+
"AxesEdge": "Automatic",
115+
"BoxRatios": "Automatic",
116+
"BoxStyle": "{}",
117+
"Boxed": "True",
118+
"ClipPlanes": "None",
119+
"ClipPlanesStyle": "Automatic",
120+
"ControllerLinking": "False",
121+
"ControllerPath": "Automatic",
122+
"FaceGrids": "None",
123+
"FaceGridsStyle": "{}",
124+
"Lighting": "Automatic",
125+
"RotationAction": "Fit",
126+
"SphericalRegion": "Automatic",
127+
"TouchscreenAutoZoom": "False",
128+
"ViewAngle": "Automatic",
129+
"ViewCenter": "Automatic",
130+
"ViewMatrix": "Automatic",
131+
"ViewPoint": "{1.3,-2.4,2.}",
132+
"ViewProjection": "Automatic",
133+
"ViewRange": "All",
134+
"ViewVector": "Automatic",
135+
"ViewVertical": "{0,0,1}",
136+
}
114137
)
115138

116139
box_suffix = "3DBox"

mathics/builtin/graphics.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,40 @@
5555
sort_order = "mathics.builtin.drawing-graphics"
5656

5757
GRAPHICS_OPTIONS = {
58+
"AlignmentPoint": "Center",
5859
"AspectRatio": "Automatic",
5960
"Axes": "False",
61+
"AxesLabel": "None",
62+
"AxesOrigin": "Automatic",
6063
"AxesStyle": "{}",
6164
"Background": "Automatic",
65+
"BaseStyle": "{}",
66+
"BaselinePosition": "Automatic",
67+
"ContentSelectable": "Automatic",
68+
"CoordinatesToolOptions": "Automatic",
69+
"Epilog": "{}",
70+
"FormatType": "TraditionalForm",
71+
"Frame": "False",
72+
"FrameLabel": "None",
73+
"FrameStyle": "{}",
74+
"FrameTicks": "Automatic",
75+
"FrameTicksStyle": "{}",
76+
"GridLines": "None",
77+
"GridLinesStyle": "{}",
78+
"ImageMargins": "0.",
79+
"ImagePadding": "All",
6280
"ImageSize": "Automatic",
6381
"LabelStyle": "{}",
82+
"Method": "Automatic",
83+
"PlotLabel": "None",
6484
"PlotRange": "Automatic",
85+
"PlotRangeClipping": "False",
6586
"PlotRangePadding": "Automatic",
87+
"PlotRegion": "Automatic",
88+
"PreserveImageOptions": "Automatic",
89+
"Prolog": "{}",
90+
"RotateLabel": "True",
91+
"Ticks": "Automatic",
6692
"TicksStyle": "{}",
6793
"$OptionSyntax": "Ignore",
6894
}

mathics/core/systemsymbols.py

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
# This list is sorted in alphabetic order.
2626
SymbolAborted = Symbol("System`$Aborted")
27-
SymbolAbsoluteTime = Symbol("AbsoluteTime")
2827
SymbolAbs = Symbol("System`Abs")
28+
SymbolAbsoluteTime = Symbol("AbsoluteTime")
2929
SymbolAccuracy = Symbol("System`Accuracy")
30+
SymbolAlignmentPoint = Symbol("System`AlignmentPoint")
3031
SymbolAll = Symbol("System`All")
3132
SymbolAlternatives = Symbol("System`Alternatives")
3233
SymbolAnd = Symbol("System`And")
@@ -40,18 +41,28 @@
4041
SymbolAssumptions = Symbol("System`$Assumptions")
4142
SymbolAttributes = Symbol("System`Attributes")
4243
SymbolAutomatic = Symbol("System`Automatic")
44+
SymbolAxesEdge = Symbol("System`AxesEdge")
45+
SymbolAxesLabel = Symbol("System`AxesLabel")
46+
SymbolAxesOrigin = Symbol("System`AxesOrigin")
4347
SymbolBaseForm = Symbol("System`BaseForm")
48+
SymbolBaseStyle = Symbol("System`BaseStyle")
49+
SymbolBaselinePosition = Symbol("System`BaselinePosition")
4450
SymbolBlack = Symbol("System`Black")
4551
SymbolBlank = Symbol("System`Blank")
4652
SymbolBlankNullSequence = Symbol("System`BlankNullSequence")
4753
SymbolBlankSequence = Symbol("System`BlankSequence")
4854
SymbolBlend = Symbol("System`Blend")
55+
SymbolBoxRatios = Symbol("System`BoxRatios")
56+
SymbolBoxStyle = Symbol("System`BoxStyle")
57+
SymbolBoxed = Symbol("System`Boxed")
4958
SymbolBreak = Symbol("System`Break")
5059
SymbolByteArray = Symbol("System`ByteArray")
5160
SymbolC = Symbol("System`C")
5261
SymbolCases = Symbol("System`Cases")
5362
SymbolCatalan = Symbol("System`Catalan")
5463
SymbolCeiling = Symbol("System`Ceiling")
64+
SymbolClipPlanes = Symbol("System`ClipPlanes")
65+
SymbolClipPlanesStyle = Symbol("System`ClipPlanesStyle")
5566
SymbolClusteringComponents = Symbol("System`ClusteringComponents")
5667
SymbolColorConvert = Symbol("System`ColorConvert")
5768
SymbolColorData = Symbol("System`ColorData")
@@ -64,9 +75,12 @@
6475
SymbolConditionalExpression = Symbol("System`ConditionalExpression")
6576
SymbolConjugate = Symbol("System`Conjugate")
6677
SymbolContainsOnly = Symbol("System`ContainsOnly")
78+
SymbolContentSelectable = Symbol("System`ContentSelectable")
6779
SymbolContext = Symbol("System`$Context")
6880
SymbolContextPath = Symbol("System`$ContextPath")
6981
SymbolContinue = Symbol("System`Continue")
82+
SymbolControllerLinking = Symbol("System`ControllerLinking")
83+
SymbolControllerPath = Symbol("System`ControllerPath")
7084
SymbolCos = Symbol("System`Cos")
7185
SymbolCosh = Symbol("System`Cosh")
7286
SymbolCot = Symbol("System`Cot")
@@ -87,6 +101,7 @@
87101
SymbolEndOfFile = Symbol("System`EndOfFile")
88102
SymbolEndOfLine = Symbol("System`EndOfLine")
89103
SymbolEndOfString = Symbol("System`EndOfString")
104+
SymbolEpilog = Symbol("System`Epilog")
90105
SymbolEqual = Symbol("System`Equal")
91106
SymbolEquivalent = Symbol("System`Equivalent")
92107
SymbolEulerGamma = Symbol("System`EulerGamma")
@@ -97,13 +112,17 @@
97112
SymbolExportString = Symbol("System`ExportString")
98113
SymbolExpression = Symbol("System`Expression")
99114
SymbolFaceForm = Symbol("System`FaceForm")
115+
SymbolFaceGrids = Symbol("System`FaceGrids")
116+
SymbolFaceGridsStyle = Symbol("System`FaceGridsStyle")
100117
SymbolFactorial = Symbol("System`Factorial")
101118
SymbolFailed = Symbol("System`$Failed")
102119
SymbolFindClusters = Symbol("System`FindClusters")
103120
SymbolFirst = Symbol("System`First")
104121
SymbolFloor = Symbol("System`Floor")
105122
SymbolFormat = Symbol("System`Format")
123+
SymbolFormatType = Symbol("System`FormatType")
106124
SymbolFractionBox = Symbol("System`FractionBox")
125+
SymbolFrameLabel = Symbol("System`FrameLabel")
107126
SymbolFull = Symbol("System`Full")
108127
SymbolFullForm = Symbol("System`FullForm")
109128
SymbolFunction = Symbol("System`Function")
@@ -126,6 +145,8 @@
126145
SymbolIf = Symbol("System`If")
127146
SymbolIm = Symbol("System`Im")
128147
SymbolImage = Symbol("System`Image")
148+
SymbolImageMargins = Symbol("System`ImageMargins")
149+
SymbolImagePadding = Symbol("System`ImagePadding")
129150
SymbolImplies = Symbol("System`Implies")
130151
SymbolIn = Symbol("System`In")
131152
SymbolIndeterminate = Symbol("System`Indeterminate")
@@ -137,14 +158,15 @@
137158
SymbolInputStream = Symbol("System`InputStream")
138159
SymbolInteger = Symbol("System`Integer")
139160
SymbolIntegrate = Symbol("System`Integrate")
161+
SymbolKey = Symbol("System`Key")
162+
SymbolKhinchin = Symbol("System`Khinchin")
140163
SymbolLast = Symbol("System`Last")
141164
SymbolLeft = Symbol("System`Left")
142165
SymbolLength = Symbol("System`Length")
143166
SymbolLess = Symbol("System`Less")
144167
SymbolLessEqual = Symbol("System`LessEqual")
145-
SymbolKey = Symbol("System`Key")
146-
SymbolKhinchin = Symbol("System`Khinchin")
147168
SymbolLetterCharacter = Symbol("System`LetterCharacter")
169+
SymbolLighting = Symbol("System`Lighting")
148170
SymbolLine = Symbol("System`Line")
149171
SymbolLog = Symbol("System`Log")
150172
SymbolLog10 = Symbol("System`Log10")
@@ -155,12 +177,12 @@
155177
SymbolMapAt = Symbol("System`MapAt")
156178
SymbolMapThread = Symbol("System`MapThread")
157179
SymbolMatchQ = Symbol("System`MatchQ")
158-
SymbolMatrixQ = Symbol("System`MatrixQ")
159180
SymbolMathMLForm = Symbol("System`MathMLForm")
160181
SymbolMatrixPower = Symbol("System`MatrixPower")
182+
SymbolMatrixQ = Symbol("System`MatrixQ")
161183
SymbolMax = Symbol("System`Max")
162-
SymbolMaxPrecision = Symbol("System`$MaxPrecision")
163184
SymbolMaxExtraPrecision = Symbol("System`$MaxExtraPrecision")
185+
SymbolMaxPrecision = Symbol("System`$MaxPrecision")
164186
SymbolMean = Symbol("System`Mean")
165187
SymbolMedian = Symbol("System`Median")
166188
SymbolMemberQ = Symbol("System`MemberQ")
@@ -179,8 +201,8 @@
179201
SymbolNot = Symbol("System`Not")
180202
SymbolNothing = Symbol("System`Nothing")
181203
SymbolNumberForm = Symbol("System`NumberForm")
182-
SymbolNumberString = Symbol("System`NumberString")
183204
SymbolNumberQ = Symbol("System`NumberQ")
205+
SymbolNumberString = Symbol("System`NumberString")
184206
SymbolNumericQ = Symbol("System`NumericQ")
185207
SymbolO = Symbol("System`O")
186208
SymbolOpacity = Symbol("System`Opacity")
@@ -191,9 +213,9 @@
191213
SymbolOptionsPattern = Symbol("System`OptionsPattern")
192214
SymbolOr = Symbol("System`Or")
193215
SymbolOut = Symbol("System`Out")
216+
SymbolOuter = Symbol("System`Outer")
194217
SymbolOutputForm = Symbol("System`OutputForm")
195218
SymbolOutputStream = Symbol("System`OutputStream")
196-
SymbolOuter = Symbol("System`Outer")
197219
SymbolOverflow = Symbol("System`Overflow")
198220
SymbolOwnValues = Symbol("System`OwnValues")
199221
SymbolPackages = Symbol("System`$Packages")
@@ -205,12 +227,17 @@
205227
SymbolPi = Symbol("System`Pi")
206228
SymbolPiecewise = Symbol("System`Piecewise")
207229
SymbolPlot = Symbol("System`Plot")
230+
SymbolPlotLabel = Symbol("System`PlotLabel")
231+
SymbolPlotRangeClipping = Symbol("System`PlotRangeClipping")
232+
SymbolPlotRegion = Symbol("System`PlotRegion")
208233
SymbolPlus = Symbol("System`Plus")
209234
SymbolPoint = Symbol("System`Point")
210-
SymbolPower = Symbol("System`Power")
211235
SymbolPolygon = Symbol("System`Polygon")
212236
SymbolPossibleZeroQ = Symbol("System`PossibleZeroQ")
237+
SymbolPower = Symbol("System`Power")
213238
SymbolPrecision = Symbol("System`Precision")
239+
SymbolPreserveImageOptions = Symbol("System`PreserveImageOptions")
240+
SymbolProlog = Symbol("System`Prolog")
214241
SymbolQuantity = Symbol("System`Quantity")
215242
SymbolQuiet = Symbol("System`Quiet")
216243
SymbolQuotient = Symbol("System`Quotient")
@@ -232,6 +259,7 @@
232259
SymbolReturn = Symbol("System`Return")
233260
SymbolReverse = Symbol("System`Reverse")
234261
SymbolRight = Symbol("System`Right")
262+
SymbolRotationAction = Symbol("System`RotationAction")
235263
SymbolRound = Symbol("System`Round")
236264
SymbolRow = Symbol("System`Row")
237265
SymbolRowBox = Symbol("System`RowBox")
@@ -251,6 +279,7 @@
251279
SymbolSort = Symbol("System`Sort")
252280
SymbolSortBy = Symbol("System`SortBy")
253281
SymbolSparseArray = Symbol("System`SparseArray")
282+
SymbolSphericalRegion = Symbol("System`SphericalRegion")
254283
SymbolSplit = Symbol("System`Split")
255284
SymbolSqrt = Symbol("System`Sqrt")
256285
SymbolSqrtBox = Symbol("System`SqrtBox")
@@ -269,22 +298,24 @@
269298
SymbolStringSplit = Symbol("System`StringSplit")
270299
SymbolStyle = Symbol("System`Style")
271300
SymbolSubValues = Symbol("System`SubValues")
272-
SymbolSubsetQ = Symbol("System`SubsetQ")
273-
SymbolSubtract = Symbol("System`Subtract")
274301
SymbolSubscriptBox = Symbol("System`SubscriptBox")
302+
SymbolSubsetQ = Symbol("System`SubsetQ")
275303
SymbolSubsuperscriptBox = Symbol("System`SubsuperscriptBox")
304+
SymbolSubtract = Symbol("System`Subtract")
276305
SymbolSuperscriptBox = Symbol("System`SuperscriptBox")
277306
SymbolTable = Symbol("System`Table")
278307
SymbolTake = Symbol("System`Take")
279308
SymbolTan = Symbol("System`Tan")
280309
SymbolTanh = Symbol("System`Tanh")
281310
SymbolTeXForm = Symbol("System`TeXForm")
282-
SymbolTimes = Symbol("System`Times")
283-
SymbolThrow = Symbol("System`Throw")
284311
SymbolThreshold = Symbol("System`Threshold")
312+
SymbolThrow = Symbol("System`Throw")
313+
SymbolTicks = Symbol("System`Ticks")
314+
SymbolTimes = Symbol("System`Times")
285315
SymbolToExpression = Symbol("System`ToExpression")
286316
SymbolToString = Symbol("System`ToString")
287317
SymbolTotal = Symbol("System`Total")
318+
SymbolTouchscreenAutoZoom = Symbol("System`TouchscreenAutoZoom")
288319
SymbolTraditionalForm = Symbol("System`TraditionalForm")
289320
SymbolTuples = Symbol("System`Tuples")
290321
SymbolUndefined = Symbol("System`Undefined")
@@ -294,6 +325,14 @@
294325
SymbolVariance = Symbol("System`Variance")
295326
SymbolVerbatim = Symbol("Verbatim")
296327
SymbolVertexColors = Symbol("VertexColors")
328+
SymbolViewAngle = Symbol("System`ViewAngle")
329+
SymbolViewCenter = Symbol("System`ViewCenter")
330+
SymbolViewMatrix = Symbol("System`ViewMatrix")
331+
SymbolViewPoint = Symbol("System`ViewPoint")
332+
SymbolViewProjection = Symbol("System`ViewProjection")
333+
SymbolViewRange = Symbol("System`ViewRange")
334+
SymbolViewVector = Symbol("System`ViewVector")
335+
SymbolViewVertical = Symbol("System`ViewVertical")
297336
SymbolWhitespace = Symbol("System`Whitespace")
298337
SymbolWhitespaceCharacter = Symbol("System`WhitespaceCharacter")
299338
SymbolWord = Symbol("System`Word")

0 commit comments

Comments
 (0)