1212
1313import numpy as np
1414
15+ from mathics .builtin .drawing import plot
1516from mathics .builtin .drawing .graphics3d import Graphics3D
1617from mathics .builtin .graphics import Graphics
1718from mathics .builtin .options import filter_from_iterable , options_to_rules
2122from mathics .core .evaluation import Evaluation
2223from mathics .core .systemsymbols import Symbol , SymbolPlotRange , SymbolSequence
2324
24- from . import plot
25-
2625# This tells documentation how to sort this module
2726sort_order = "mathics.builtin.custom-plots"
2827
@@ -143,9 +142,10 @@ def eval(
143142
144143class ComplexPlot3D (_Plot3D ):
145144 """
146- <url>:WMA link: https://reference.wolfram.com/language/ref/ComplexPlot3D.html</url>
145+ <url>:Domain coloring:https://en.wikipedia.org/wiki/Domain_coloring</url> (<url>
146+ :WMA link: https://reference.wolfram.com/language/ref/ComplexPlot3D.html</url>)
147147 <dl>
148- <dt>'Plot3D '[$f$, {$z$, $z_{min}$, $z_{max}$}]
148+ <dt>'ComplexPlot3D '[$f$, {$z$, $z_{min}$, $z_{max}$}]
149149 <dd>creates a three-dimensional plot of the magnitude of $f$ with $z$ ranging from $z_{min}$ to \
150150 $z_{max}$ with surface colored according to phase
151151
@@ -154,21 +154,29 @@ class ComplexPlot3D(_Plot3D):
154154 </url> for a list of Plot options.
155155 </dl>
156156
157+ 'ComplexPlot' allows to visualize the changes both in the phase and \
158+ the module of a complex function:
159+
160+ In the neighborhood of the poles, the module of a rational function \
161+ grows without limit, and the phase varies between $-\\ Pi$ to $\\ Pi$, \
162+ an integer number of times:
163+ >> ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I}]
164+ = ...
157165 """
158166
159- summary_text = "plots one or more complex functions as a 3D surface"
167+ graphics_class = Graphics3D
160168 expected_args = 2
161- options = _Plot3D .options3d | {"Mesh" : "None" }
162-
163169 many_functions = True
164- graphics_class = Graphics3D
170+ options = _Plot3D .options3d | {"Mesh" : "None" }
171+ summary_text = "plot one or more complex functions as a 3D surface"
165172
166173
167174class ComplexPlot (_Plot3D ):
168175 """
176+ <url>:Domain coloring:https://en.wikipedia.org/wiki/Domain_coloring</url>
169177 <url>:WMA link: https://reference.wolfram.com/language/ref/ComplexPlot.html</url>
170178 <dl>
171- <dt>'Plot3D '[$f$, {$z$, $z_{min}$, $z_{max}$}]
179+ <dt>'ComplexPlot '[$f$, {$z$, $z_{min}$, $z_{max}$}]
172180 <dd>creates two-dimensional plot of $f$ with $z$ ranging from $z_{min}$ to \
173181 $z_{max}$ colored according to phase
174182
@@ -177,39 +185,58 @@ class ComplexPlot(_Plot3D):
177185 </url> for a list of Plot options.
178186 </dl>
179187
188+ 'ComplexPlot' allows to visualize the changes in the phase of a \
189+ complex function.
190+ In the neighborhood of the poles, the module of a rational function \
191+ the phase varies between $-\\ Pi$ to $\\ Pi$ an integer number of times.
192+ >> ComplexPlot[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I}]
193+ = ...
180194 """
181195
182- summary_text = "plots a complex function showing phase using colors"
183196 expected_args = 2
184- options = _Plot3D .options2d
185-
186- many_functions = False
187197 graphics_class = Graphics
198+ many_functions = False
199+ options = _Plot3D .options2d
200+ summary_text = "plots a complex function showing phase using colors"
188201
189202
190203class ContourPlot (_Plot3D ):
191204 """
192- <url>:WMA link: https://reference.wolfram.com/language/ref/ContourPlot.html</url>
205+ <url>:heat map:https://en.wikipedia.org/wiki/Heat_map</url>, <url>
206+ :contour map:https://en.wikipedia.org/wiki/Contour_line</url> (<url>
207+ :WMA link: https://reference.wolfram.com/language/ref/ContourPlot.html</url>)
193208 <dl>
194209 <dt>'Contour'[$f$, {$x$, $x_{min}$, $x_{max}$}, {$y$, $y_{min}$, $y_{max}$}]
195- <dd>creates a two-dimensional contour plot ofh $f$ over the region
210+ <dd>creates a two-dimensional contour plot ofh $f$ over the region \
196211 $x$ ranging from $x_{min}$ to $x_{max}$ and $y$ ranging from $y_{min}$ to $y_{max}$.
197212
198213 See <url>:Drawing Option and Option Values:
199214 /doc/reference-of-built-in-symbols/plotting-graphing-and-drawing/drawing-options-and-option-values
200215 </url> for a list of Plot options.
201216 </dl>
202217
218+ Colorize the regions where a function takes values close to different \
219+ numeric values
220+ >> ContourPlot[x - y^3, {x, -2, 2}, {y, -1, 1}, AspectRatio->Automatic]
221+ = ...
222+
223+ The same, but with a finer division:
224+ >> ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -1, 1}, Contours->10]
225+ = ...
226+
227+ Plot curves where the real and the imaginary part of a function take
228+ specific values:
229+ >> ContourPlot[{Re[Sin[x + I y]] == 5, Im[Sin[x + I y]] == 0}, {x, -10, 10}, {y, -10, 10}]
230+ = ...
203231 """
204232
205- requires = ["skimage" ]
206- summary_text = "creates a contour plot"
207233 expected_args = 3
234+ graphics_class = Graphics
235+ many_functions = True
208236 options = _Plot3D .options2d | {"Contours" : "Automatic" }
209237 # TODO: other options?
210-
211- many_functions = True
212- graphics_class = Graphics
238+ requires = ["skimage" ]
239+ summary_text = "creates a contour plot"
213240
214241
215242class DensityPlot (_Plot3D ):
@@ -236,12 +263,11 @@ class DensityPlot(_Plot3D):
236263 = -Graphics-
237264 """
238265
239- summary_text = "density plot for a function"
240266 expected_args = 3
241- options = _Plot3D .options2d
242-
243- many_functions = False
244267 graphics_class = Graphics
268+ many_functions = False
269+ options = _Plot3D .options2d
270+ summary_text = "density plot for a function"
245271
246272
247273class Plot3D (_Plot3D ):
@@ -273,9 +299,8 @@ class Plot3D(_Plot3D):
273299 = -Graphics3D-
274300 """
275301
276- summary_text = "plots 3D surfaces of one or more functions"
277302 expected_args = 3
278- options = _Plot3D .options3d
279-
280- many_functions = True
281303 graphics_class = Graphics3D
304+ many_functions = True
305+ options = _Plot3D .options3d
306+ summary_text = "plots 3D surfaces of one or more functions"
0 commit comments