2 * Introduction to draw::
3 * Functions and Variables for draw::
4 * Functions and Variables for pictures::
5 * Functions and Variables for worldmap::
10 @node Introduction to draw, Functions and Variables for draw, draw-pkg, draw-pkg
11 @section Introduction to draw
14 @code{draw} is a Maxima-Gnuplot and a Maxima-VTK interface.
16 There are three main functions to be used at Maxima level:
18 @item @mrefcomma{draw2d} draws a single 2D scene.
19 @item @mrefcomma{draw3d} draws a single 3D scene.
20 @item @mrefcomma{draw} can be filled with multiple @mref{gr2d} and @mref{gr3d}
21 commands that each creates a draw scene all sharing the same window.
23 Each scene can contain any number of objects and @code{key=value} pairs
24 with options for the scene or the following objects.
26 A selection of useful objects a scene can be made up from are:
28 @item @mref{explicit} plots a function.
29 @item @mref{implicit} plots all points an equation is true at.
30 @item @mref{points} plots points that are connected by lines if the option
31 @mref{points_joined} was set to @code{true} in a previous line of the
33 @item @mref{parametric} allows to specify separate expressions that calculate
34 the x, y (and in 3d plots also for the z) variable.
37 A short description of all draw commands and options including example plots
38 (in the html and pdf version of this manual) can be found in the section
39 @xref{Functions and Variables for draw}. An online version of the html manual can be
40 found at @url{https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html#draw}.
41 More elaborated examples of this package can be found at the following locations:
43 @url{http://riotorto.users.sourceforge.net/Maxima/gnuplot/} @*
44 @url{http://riotorto.users.sourceforge.net/Maxima/vtk/}
50 title="Two simple plots",
51 xlabel="x",ylabel="y",grid=true,
53 color=red,key="A sinus",
54 explicit(sin(x),x,1,10),
55 color=blue,line_type=dots,key="A cosinus",
56 explicit(cos(x),x,1,10)
61 You need Gnuplot 4.2 or newer to run draw; If you are using wxMaxima as a
62 front end @code{wxdraw}, @code{wxdraw2d} and @code{wxdraw3d} are drop-in
63 replacements for draw that do the same as @mrefcomma{draw} @mref{draw2d} and
64 @mref{draw3d} but embed the resulting plot in the worksheet.
66 If you want to use VTK with draw, you need VTK with the Python interface installed
67 (the @ref{dynamics-pkg} uses VTK with the TCL interface!) and set the variable:
69 @code{draw_renderer: 'vtk $}
71 @opencatbox{Categories:}
73 @category{Share packages}
74 @category{Package draw}
78 @node Functions and Variables for draw, Functions and Variables for pictures, Introduction to draw, draw-pkg
79 @section Functions and Variables for draw
88 @deffn {Scene constructor} gr2d (@var{argument_1}, ...)
90 Function @code{gr2d} builds an object describing a 2D scene. Arguments are
91 @i{graphic options}, @i{graphic objects}, or lists containing both graphic options and objects.
92 This scene is interpreted sequentially: @i{graphic options} affect those @i{graphic objects}
93 placed on its right. Some @i{graphic options} affect the global appearance of the scene.
95 This is the list of @i{graphic objects} available for scenes in two dimensions:
96 @mrefcomma{bars} @mrefcomma{ellipse} @mrefcomma{explicit} @mrefcomma{image} @mrefcomma{implicit} @mrefcomma{label}
97 @mrefcomma{parametric} @mrefcomma{points} @mrefcomma{polar} @mrefcomma{polygon} @mrefcomma{quadrilateral}
98 @mrefcomma{rectangle} @mrefcomma{triangle} @mref{vector} and @code{geomap}
99 (this one defined in package @code{worldmap}).
107 @c key="sin (x)",grid=[2,2],
114 @c key="cos (x)",grid=[2,2],
125 key="sin (x)",grid=[2,2],
132 key="cos (x)",grid=[2,2],
139 (%o1) [gr2d(explicit), gr2d(explicit)]
144 @opencatbox{Categories:}
145 @category{Package draw}
152 @deffn {Scene constructor} gr3d (@var{argument_1}, ...)
154 Function @code{gr3d} builds an object describing a 3d scene. Arguments are
155 @i{graphic options}, @i{graphic objects}, or lists containing both graphic options
156 and objects. This scene is interpreted sequentially: @i{graphic options} affect those
157 @i{graphic objects} placed on its right. Some @i{graphic options} affect the global
158 appearance of the scene.
160 This is the list of @i{graphic objects} available for scenes in three
162 @mrefcomma{cylindrical} @mrefcomma{elevation_grid} @mrefcomma{explicit} @mrefcomma{implicit}
163 @mrefcomma{label} @mrefcomma{mesh} @mrefcomma{parametric}@*
164 @mrefcomma{parametric_surface} @mrefcomma{points} @mrefcomma{quadrilateral}
165 @mrefcomma{spherical} @mrefcomma{triangle} @mrefcomma{tube}@*
166 @mrefcomma{vector} and @mref{geomap} (this one defined in package @code{worldmap}).
168 See also @mref{draw} and @mrefdot{draw3d}
170 @opencatbox{Categories:}
171 @category{Package draw}
179 @subsection Functions
184 @deffn {Function} draw (@code{<arg_1>, ...})
186 Plots a series of scenes; its arguments are @code{gr2d} and/or @code{gr3d}
187 objects, together with some options, or lists of scenes and options.
188 By default, the scenes are put together
191 Besides scenes the function @code{draw} accepts the following global options:
192 @mrefcomma{terminal} @mrefcomma{columns} @mrefcomma{dimensions} @mref{file_name}
195 Functions @mref{draw2d} and @mref{draw3d} short cuts that can be used
196 when only one scene is required, in two or three dimensions, respectively.
198 See also @mref{gr2d} and @mrefdot{gr3d}
203 (%i1) scene1: gr2d(title="Ellipse",
205 parametric(2*cos(t),5*sin(t),t,0,2*%pi))$
206 (%i2) scene2: gr2d(title="Triangle",
207 polygon([4,5,7],[6,4,2]))$
208 (%i3) draw(scene1, scene2, columns = 2)$
213 (%i1) scene1: gr2d(title="A sinus",
215 explicit(sin(t),t,0,2*%pi))$
216 (%i2) scene2: gr2d(title="A cosinus",
218 explicit(cos(t),t,0,2*%pi))$
219 (%i3) draw(scene1, scene2)$
223 The following two draw sentences are equivalent:
225 (%i1) draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1)));
226 (%o1) [gr3d(explicit)]
227 (%i2) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1));
228 (%o2) [gr3d(explicit)]
231 Creating an animated gif file:
236 terminal = 'animated_gif,
237 gr2d(explicit(x^2,x,-1,1)),
238 gr2d(explicit(x^3,x,-1,1)),
239 gr2d(explicit(x^4,x,-1,1)));
240 End of animation sequence
241 (%o1) [gr2d(explicit), gr2d(explicit), gr2d(explicit)]
244 See also @mrefcomma{gr2d} @mrefcomma{gr3d} @mref{draw2d} and @mrefdot{draw3d}
246 @opencatbox{Categories:}
247 @category{Package draw}
248 @category{File output}
257 @deffn {Function} draw2d (@var{argument_1}, ...)
259 This function is a shortcut for
260 @code{draw(gr2d(@var{options}, ..., @var{graphic_object}, ...))}.
262 It can be used to plot a unique scene in 2d, as can be seen in most examples below.
264 See also @mref{draw} and @mrefdot{gr2d}
266 @opencatbox{Categories:}
267 @category{Package draw}
268 @category{File output}
278 @deffn {Function} draw3d (@var{argument_1}, ...)
280 This function is a shortcut for
281 @code{draw(gr3d(@var{options}, ..., @var{graphic_object}, ...))}.
283 It can be used to plot a unique scene in 3d, as can be seen in many examples below.
285 See also @mref{draw} and @mrefdot{gr3d}
287 @opencatbox{Categories:}
288 @category{Package draw}
289 @category{File output}
296 @deffn {Function} draw_file (@var{graphic option}, ..., @var{graphic object}, ...)
298 Saves the current plot into a file. Accepted graphics options are:
299 @code{terminal}, @code{dimensions} and @code{file_name}.
304 (%i1) /* screen plot */
305 draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1)))$
306 (%i2) /* same plot in eps format */
307 draw_file(terminal = eps,
308 dimensions = [5,5]) $
311 @opencatbox{Categories:}
312 @category{Package draw}
313 @category{File output}
319 @anchor{multiplot_mode}
320 @deffn {Function} multiplot_mode (@var{term})
322 This function enables Maxima to work in one-window multiplot mode with terminal
323 @var{term}; accepted arguments for this function are @code{screen},
324 @code{wxt}, @code{aquaterm}, @code{windows} and @code{none}.
326 When multiplot mode is enabled, each call to @code{draw} sends a new plot to the
327 same window, without erasing the previous ones. To disable the multiplot mode,
328 write @code{multiplot_mode(none)}.
330 When multiplot mode is enabled, global option @code{terminal} is blocked and you
331 have to disable this working mode before changing to another terminal.
333 On Windows this feature requires Gnuplot 5.0 or newer.
334 Note, that just plotting multiple expressions into the same plot doesn't require
335 multiplot: It can be done by just issuing multiple @mref{explicit} or similar
341 (%i1) set_draw_defaults(
345 title = "Step by step plot" )$
346 (%i2) multiplot_mode(screen)$
347 (%i3) draw2d(color=blue, explicit(x^2,x,-1,1))$
348 (%i4) draw2d(color=red, explicit(x^3,x,-1,1))$
349 (%i5) draw2d(color=brown, explicit(x^4,x,-1,1))$
350 (%i6) multiplot_mode(none)$
352 @figure{draw_multiplot}
354 @opencatbox{Categories:}
355 @category{Package draw}
356 @category{File output}
364 @anchor{set_draw_defaults}
365 @deffn {Function} set_draw_defaults (@var{graphic option}, ..., @var{graphic object}, ...)
367 Sets user graphics options. This function is useful for plotting a sequence
368 of graphics with common graphics options. Calling this function without
369 arguments removes user defaults.
374 (%i1) set_draw_defaults(
379 (%i2) /* plot with user defaults */
380 draw2d(explicit(((1+x)**2/(1+x*x))-1,x,-10,10))$
381 (%i3) set_draw_defaults()$
382 (%i4) /* plot with standard defaults */
383 draw2d(explicit(((1+x)**2/(1+x*x))-1,x,-10,10))$
386 @opencatbox{Categories:}
387 @category{Package draw}
392 @subsection Plot options for draw programs
394 @anchor{adapt_depth_draw}
395 @defvr {Graphic option} adapt_depth
398 @code{adapt_depth} is the maximum number of splittings used by the adaptive plotting routine.
400 This option is relevant only for 2d @code{explicit} functions.
402 See also @code{nticks}
404 @opencatbox{Categories:}
405 @category{Package draw}
411 @defvr {Graphic option} allocation
412 Default value: @code{false}
414 With option @code{allocation} it is possible to place a scene in the
415 output window at will; this is of interest in multiplots. When @code{false},
416 the scene is placed automatically, depending on the value assigned to option
417 @code{columns}. In any other case, @code{allocation} must be set to a list of
418 two pairs of numbers; the first corresponds to the position of the lower left
419 corner of the scene, and the second pair gives the width and height of the plot.
420 All quantities must be given in relative coordinates, between 0 and 1.
429 explicit(x^2,x,-1,1)),
431 allocation = [[1/4, 1/4],[1/2, 1/2]],
432 explicit(x^3,x,-1,1),
435 @figure{draw_allocation}
437 Multiplot with selected dimensions.
444 allocation = [[0, 0],[1, 1/4]],
445 explicit(x^2,x,-1,1)),
447 allocation = [[0, 1/4],[1, 3/4]],
448 explicit(x^2+y^2,x,-1,1,y,-1,1) ))$
450 @figure{draw_allocation2}
452 See also option @mrefdot{columns}
454 @opencatbox{Categories:}
455 @category{Package draw}
462 @defvr {Graphic option} axis_3d
463 Default value: @code{true}
465 If @code{axis_3d} is @code{true}, the @var{x}, @var{y} and @var{z} axis are shown in 3d scenes.
467 Since this is a global graphics option, its position in the scene description
473 (%i1) draw3d(axis_3d = false,
474 explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$
478 See also @mrefcomma{axis_bottom} @mrefcomma{axis_left} @mrefcomma{axis_top} and @mref{axis_right} for axis in 2d.
480 @opencatbox{Categories:}
481 @category{Package draw}
489 @defvr {Graphic option} axis_bottom
490 Default value: @code{true}
492 If @code{axis_bottom} is @code{true}, the bottom axis is shown in 2d scenes.
494 Since this is a global graphics option, its position in the scene description
500 (%i1) draw2d(axis_bottom = false,
501 explicit(x^3,x,-1,1))$
503 @figure{draw_axis_bottom}
505 See also @mrefcomma{axis_left} @mrefcomma{axis_top} @mref{axis_right} and @mrefdot{axis_3d}
507 @opencatbox{Categories:}
508 @category{Package draw}
516 @defvr {Graphic option} axis_left
517 Default value: @code{true}
519 If @code{axis_left} is @code{true}, the left axis is shown in 2d scenes.
521 Since this is a global graphics option, its position in the scene description
527 (%i1) draw2d(axis_left = false,
528 explicit(x^3,x,-1,1))$
531 See also @mrefcomma{axis_bottom} @mrefcomma{axis_top} @mref{axis_right} and @mrefdot{axis_3d}
533 @opencatbox{Categories:}
534 @category{Package draw}
542 @defvr {Graphic option} axis_right
543 Default value: @code{true}
545 If @code{axis_right} is @code{true}, the right axis is shown in 2d scenes.
547 Since this is a global graphics option, its position in the scene description
553 (%i1) draw2d(axis_right = false,
554 explicit(x^3,x,-1,1))$
557 See also @mrefcomma{axis_bottom} @mrefcomma{axis_left} @mref{axis_top} and @mrefdot{axis_3d}
559 @opencatbox{Categories:}
560 @category{Package draw}
568 @defvr {Graphic option} axis_top
569 Default value: @code{true}
571 If @code{axis_top} is @code{true}, the top axis is shown in 2d scenes.
573 Since this is a global graphics option, its position in the scene description
579 (%i1) draw2d(axis_top = false,
580 explicit(x^3,x,-1,1))$
583 See also @mrefcomma{axis_bottom} @mrefcomma{axis_left} @mrefcomma{axis_right} and @mrefdot{axis_3d}
585 @opencatbox{Categories:}
586 @category{Package draw}
593 @anchor{background_color}
594 @defvr {Graphic option} background_color
595 Default value: @code{white}
597 Sets the background color for terminals. Default background color is white.
599 Since this is a global graphics option, its position in the scene description
602 This option does not work with terminals @code{epslatex} and @code{epslatex_standalone}.
604 See also @code{color}
606 @opencatbox{Categories:}
607 @category{Package draw}
615 @defvr {Graphic option} border
616 Default value: @code{true}
618 If @code{border} is @code{true}, borders of polygons are painted
619 according to @code{line_type} and @code{line_width}.
621 This option affects the following graphic objects:
625 @code{gr2d}: @mrefcomma{polygon} @mref{rectangle} and @mrefdot{ellipse}
631 (%i1) draw2d(color = brown,
633 polygon([[3,2],[7,2],[5,5]]),
636 polygon([[5,2],[9,2],[7,5]]) )$
640 @opencatbox{Categories:}
641 @category{Package draw}
649 @defvr {Graphic option} capping
650 Default value: @code{[false, false]}
652 A list with two possible elements, @code{true} and @code{false},
653 indicating whether the extremes of a graphic object @code{tube} remain closed
654 or open. By default, both extremes are left open.
656 Setting @code{capping = false} is equivalent to @code{capping = [false, false]},
657 and @code{capping = true} is equivalent to @code{capping = [true, true]}.
663 capping = [false, true],
667 @figure{draw_tube_extremes}
669 @opencatbox{Categories:}
670 @category{Package draw}
678 @defvr {Graphic option} cbrange
679 Default value: @code{auto}
681 If @code{cbrange} is @code{auto}, the range for the values which are
682 colored when @code{enhanced3d} is not @code{false} is computed
683 automatically. Values outside of the color range use color of the
686 When @code{enhanced3d} or @code{colorbox} is @code{false}, option @code{cbrange} has
689 If the user wants a specific interval for the colored values, it must
690 be given as a Maxima list, as in @code{cbrange=[-2, 3]}.
692 Since this is a global graphics option, its position in the scene description
702 explicit(x^2+y^2, x,-2,2,y,-2,2)) $
704 @figure{draw_cbrange}
706 See also @mrefcomma{enhanced3d} @mref{colorbox} and @mrefdot{cbtics}
708 @opencatbox{Categories:}
709 @category{Package draw}
716 @defvr {Graphic option} cbtics
717 Default value: @code{auto}
719 This graphic option controls the way tic marks are drawn on the colorbox
720 when option @code{enhanced3d} is not @code{false}.
722 When @code{enhanced3d} or @code{colorbox} is @code{false}, option @code{cbtics} has
725 See @code{xtics} for a complete description.
733 cbtics = @{["High",10],["Medium",05],["Low",0]@},
735 explicit(x^2+y^2, x,-2,2,y,-2,2)) $
739 See also @mrefcomma{enhanced3d} @mref{colorbox} and @mrefdot{cbrange}
741 @opencatbox{Categories:}
742 @category{Package draw}
748 @defvr {Graphic option} color
749 Default value: @code{blue}
751 @code{color} specifies the color for plotting lines, points, borders of
754 Colors can be given as names or in hexadecimal @i{rgb} code. If a gnuplot
755 version @code{>= 5.0} is used and the terminal that is in use supports this
756 @i{rgba} colors with transparency information are also supported.
758 Available color names are:
760 white black gray0 grey0
761 gray10 grey10 gray20 grey20
762 gray30 grey30 gray40 grey40
763 gray50 grey50 gray60 grey60
764 gray70 grey70 gray80 grey80
765 gray90 grey90 gray100 grey100
766 gray grey light_gray light_grey
767 dark_gray dark_grey red light_red
768 dark_red yellow light_yellow dark_yellow
769 green light_green dark_green spring_green
770 forest_green sea_green blue light_blue
771 dark_blue midnight_blue navy medium_blue
772 royalblue skyblue cyan light_cyan
773 dark_cyan magenta light_magenta dark_magenta
774 turquoise light_turquoise dark_turquoise pink
775 light_pink dark_pink coral light_coral
776 orange_red salmon light_salmon dark_salmon
777 aquamarine khaki dark_khaki goldenrod
778 light_goldenrod dark_goldenrod gold beige
779 brown orange dark_orange violet
780 dark_violet plum purple
783 Cromatic components in hexadecimal code are introduced in the form @code{"#rrggbb"}.
788 (%i1) draw2d(explicit(x^2,x,-1,1), /* default is black */
790 explicit(0.5 + x^2,x,-1,1),
792 explicit(1 + x^2,x,-1,1),
794 explicit(1.5 + x^2,x,-1,1),
796 label(["This is a label",0,1.2]) )$
803 explicit(sin(x),x,0,10),
805 explicit(cos(x),x,0,10)
811 (%i1) H(p,p_0) := %i/(2*%pi*(p-p_0))$
813 proportional_axes=xy,
818 color=printf(false,"#~2,'0x~2,'0x~2,'0x",i*10,0,0),
820 key = if mod(i,5)=0 then sconcat("H=",i,"A/M") else "",
822 cabs(H(x+%i*y,-1-%i)+H(x+%i*y,1+%i)-H(x+%i*y,1-%i)
823 -H(x+%i*y,-1+%i))=i/10,
836 "figures/draw_color4",
840 key=sconcat("color =",i),
841 explicit(sin(i*x),x,0,1)
850 See also @mrefdot{fill_color}
852 @opencatbox{Categories:}
853 @category{Package draw}
861 @defvr {Graphic option} colorbox
862 Default value: @code{true}
864 If @code{colorbox} is @code{true}, a color scale without label is drawn together with
865 @code{image} 2D objects, or coloured 3d objects. If @code{colorbox} is @code{false}, no
866 color scale is shown. If @code{colorbox} is a string, a color scale with label is drawn.
868 Since this is a global graphics option, its position in the scene description
873 Color scale and images.
876 (%i1) im: apply('matrix,
877 makelist(makelist(random(200),i,1,30),i,1,30))$
879 gr2d(image(im,0,0,30,30)),
880 gr2d(colorbox = false, image(im,0,0,30,30))
883 @figure{draw_colorbox}
884 Color scale and 3D coloured object.
888 colorbox = "Magnitude",
890 explicit(x^2+y^2,x,-1,1,y,-1,1))$
892 @figure{draw_colorbox2}
894 See also @mrefdot{palette_draw}
896 @opencatbox{Categories:}
897 @category{Package draw}
906 @defvr {Graphic option} columns
909 @code{columns} is the number of columns in multiple plots.
911 Since this is a global graphics option, its position in the scene description
912 does not matter. It can be also used as an argument of function @code{draw}.
917 (%i1) scene1: gr2d(title="Ellipse",
919 parametric(2*cos(t),5*sin(t),t,0,2*%pi))$
920 (%i2) scene2: gr2d(title="Triangle",
921 polygon([4,5,7],[6,4,2]))$
922 (%i3) draw(scene1, scene2, columns = 2)$
924 @figure{draw_columns}
926 @opencatbox{Categories:}
927 @category{Package draw}
935 @defvr {Graphic option} contour
936 Default value: @code{none}
938 Option @code{contour} enables the user to select where to plot contour lines.
945 no contour lines are plotted.
949 contour lines are projected on the xy plane.
953 contour lines are plotted on the surface.
957 two contour lines are plotted: on the xy plane and on the surface.
961 contour lines are projected on the xy plane, and the view point is
962 set just in the vertical.
966 Since this is a global graphics option, its position in the scene description
972 (%i1) draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
975 surface_hide = true) $
977 @figure{draw_contour}
980 (%i1) draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
985 @figure{draw_contour2}
987 @opencatbox{Categories:}
988 @category{Package draw}
995 @anchor{contour_levels}
996 @defvr {Graphic option} contour_levels
999 This graphic option controls the way contours are drawn.
1000 @code{contour_levels} can be set to a positive integer number, a list of three
1001 numbers or an arbitrary set of numbers:
1005 When option @code{contour_levels} is bounded to positive integer @var{n},
1006 @var{n} contour lines will be drawn at equal intervals. By default, five
1007 equally spaced contours are plotted.
1010 When option @code{contour_levels} is bounded to a list of length three of the
1011 form @code{[lowest,s,highest]}, contour lines are plotted from @code{lowest}
1012 to @code{highest} in steps of @code{s}.
1015 When option @code{contour_levels} is bounded to a set of numbers of the
1016 form @code{@{n1, n2, ...@}}, contour lines are plotted at values @code{n1},
1020 Since this is a global graphics option, its position in the scene description
1025 Ten equally spaced contour lines. The actual number of
1026 levels can be adjusted to give simple labels.
1028 (%i1) draw3d(color = green,
1029 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
1030 contour_levels = 10,
1032 surface_hide = true) $
1036 From -8 to 8 in steps of 4.
1038 (%i1) draw3d(color = green,
1039 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
1040 contour_levels = [-8,4,8],
1042 surface_hide = true) $
1045 Isolines at levels -7, -6, 0.8 and 5.
1047 (%i1) draw3d(color = green,
1048 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
1049 contour_levels = @{-7, -6, 0.8, 5@},
1051 surface_hide = true) $
1054 See also @mrefdot{contour}
1056 @opencatbox{Categories:}
1057 @category{Package draw}
1064 @anchor{data_file_name}
1065 @defvr {Graphic option} data_file_name
1066 Default value: @code{"data.gnuplot"}
1068 This is the name of the file with the numeric data needed
1069 by Gnuplot to build the requested plot.
1071 Since this is a global graphics option, its position in the scene description
1072 does not matter. It can be also used as an argument of function @code{draw}.
1074 See example in @code{gnuplot_file_name}.
1076 @opencatbox{Categories:}
1077 @category{Package draw}
1085 @defvr {Graphic option} delay
1088 This is the delay in 1/100 seconds of frames in animated gif files.
1090 Since this is a global graphics option, its position in the scene description
1091 does not matter. It can be also used as an argument of function @code{draw}.
1099 terminal = 'animated_gif,
1100 gr2d(explicit(x^2,x,-1,1)),
1101 gr2d(explicit(x^3,x,-1,1)),
1102 gr2d(explicit(x^4,x,-1,1)));
1103 End of animation sequence
1104 (%o2) [gr2d(explicit), gr2d(explicit), gr2d(explicit)]
1107 Option @code{delay} is only active in animated gif's; it is ignored in
1110 See also @mrefcomma{terminal} and @code{dimensions}.
1112 @opencatbox{Categories:}
1113 @category{Package draw}
1120 @anchor{dimensions_draw}
1121 @defvr {Graphic option} dimensions
1122 Default value: @code{[600,500]}
1124 Dimensions of the output terminal. Its value is a list formed by
1125 the width and the height. The meaning of the two numbers depends on
1126 the terminal you are working with.
1128 With terminals @code{gif}, @code{animated_gif}, @code{png}, @code{jpg},
1129 @code{svg}, @code{screen}, @code{wxt}, and @code{aquaterm},
1130 the integers represent the number of points in each direction. If they
1131 are not integers, they are rounded.
1133 With terminals @code{eps}, @code{eps_color}, @code{pdf}, and
1134 @code{pdfcairo}, both numbers represent hundredths of cm, which
1135 means that, by default, pictures in these formats are 6 cm in
1136 width and 5 cm in height.
1138 Since this is a global graphics option, its position in the scene description
1139 does not matter. It can be also used as an argument of function @code{draw}.
1143 Option @code{dimensions} applied to file output
1148 dimensions = [300,300],
1150 explicit(x^4,x,-1,1)) $
1152 dimensions = [300,300],
1154 explicit(x^4,x,-1,1)) $
1157 Option @code{dimensions} applied to eps output.
1158 We want an eps file with A4 portrait dimensions.
1161 (%i1) A4portrait: 100*[21, 29.7]$
1163 dimensions = A4portrait,
1165 explicit(x^2-y^2,x,-2,2,y,-2,2)) $
1168 @opencatbox{Categories:}
1169 @category{Package draw}
1176 @anchor{draw_realpart}
1177 @defvr {Graphic option} draw_realpart
1178 Default value: @code{true}
1180 When @code{true}, functions to be drawn are considered as complex functions whose
1181 real part value should be plotted; when @code{false}, nothing will be plotted when
1182 the function does not give a real value.
1184 This option affects objects @mref{explicit} and @mref{parametric} in 2D and 3D, and
1185 @mrefdot{parametric_surface}
1190 draw_realpart = false,
1191 explicit(sqrt(x^2 - 4*x) - x, x, -1, 5),
1193 draw_realpart = true,
1194 parametric(x,sqrt(x^2 - 4*x) - x + 1, x, -1, 5) );
1197 @opencatbox{Categories:}
1198 @category{Package draw}
1206 @defvr {Graphic option} enhanced3d
1207 Default value: @code{none}
1209 If @code{enhanced3d} is @code{none}, surfaces are not colored in 3D plots.
1210 In order to get a colored surface, a list must be assigned to option
1211 @mrefcomma{enhanced3d} where the first element is an expression and the rest
1212 are the names of the variables or parameters used in that expression. A list such
1213 @code{[f(x,y,z), x, y, z]} means that point @code{[x,y,z]} of the surface
1214 is assigned number @code{f(x,y,z)}, which will be colored according to
1215 the actual @code{palette}. For those 3D graphic objects defined in terms of
1216 parameters, it is possible to define the color number in terms of
1217 the parameters, as in @code{[f(u), u]}, as in objects @mref{parametric} and
1218 @mrefcomma{tube} or @code{[f(u,v), u, v]}, as in object @code{parametric_surface}.
1219 While all 3D objects admit the model based on absolute coordinates,
1220 @code{[f(x,y,z), x, y, z]}, only two of them, namely @code{explicit}
1221 and @mrefcomma{elevation_grid} accept also models defined on the @code{[x,y]} coordinates,
1222 @code{[f(x,y), x, y]}. 3D graphic object @code{implicit} accepts only the
1223 @code{[f(x,y,z), x, y, z]} model. Object @code{points} accepts also the
1224 @code{[f(x,y,z), x, y, z]} model, but when points have a chronological nature,
1225 model @code{[f(k), k]} is also valid, being @code{k} an ordering parameter.
1227 When @code{enhanced3d} is assigned something different to @code{none}, options
1228 @code{color} and @code{surface_hide} are ignored.
1230 The names of the variables defined in the lists may be different to those
1231 used in the definitions of the graphic objects.
1233 In order to maintain back compatibility, @code{enhanced3d = false} is equivalent
1234 to @code{enhanced3d = none}, and @code{enhanced3d = true} is equivalent to
1235 @code{enhanced3d = [z, x, y, z]}. If an expression is given to @mrefcomma{enhanced3d}
1236 its variables must be the same used in the surface definition. This is not
1237 necessary when using lists.
1239 See option @code{palette} to learn how palettes are specified.
1243 @code{explicit} object with coloring defined by the @code{[f(x,y,z), x, y, z]} model.
1247 enhanced3d = [x-z/10,x,y,z],
1249 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$
1251 @figure{draw_enhanced3d}
1253 @code{explicit} object with coloring defined by the @code{[f(x,y), x, y]} model.
1254 The names of the variables defined in the lists may be different to those
1255 used in the definitions of the graphic objects; in this case, @code{r} corresponds
1256 to @code{x}, and @code{s} to @code{y}.
1260 enhanced3d = [sin(r*s),r,s],
1261 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$
1263 @figure{draw_enhanced3d2}
1265 @code{parametric} object with coloring defined by the @code{[f(x,y,z), x, y, z]} model.
1271 enhanced3d = [if y>= 0 then 1 else 0, x, y, z],
1272 parametric(sin(u)^2,cos(u),u,u,0,4*%pi)) $
1274 @figure{draw_enhanced3d3}
1276 @code{parametric} object with coloring defined by the @code{[f(u), u]} model.
1277 In this case, @code{(u-1)^2} is a shortcut for @code{[(u-1)^2,u]}.
1283 enhanced3d = (u-1)^2,
1284 parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2))$
1286 @figure{draw_enhanced3d4}
1288 @code{elevation_grid} object with coloring defined by the @code{[f(x,y), x, y]} model.
1293 makelist(makelist(cos(i^2/80-k/30),k,1,30),i,1,20)) $
1295 enhanced3d = [cos(x*y*10),x,y],
1296 elevation_grid(m,-1,-1,2,2),
1300 @figure{draw_enhanced3d5}
1302 @code{tube} object with coloring defined by the @code{[f(x,y,z), x, y, z]} model.
1306 enhanced3d = [cos(x-y),x,y,z],
1309 tube(cos(a), a, 0, 1, a, 0, 4*%pi) )$
1311 @figure{draw_enhanced3d6}
1313 @code{tube} object with coloring defined by the @code{[f(u), u]} model.
1314 Here, @code{enhanced3d = -a} would be the shortcut for @code{enhanced3d = [-foo,foo]}.
1318 capping = [true, false],
1319 palette = [26,15,-2],
1320 enhanced3d = [-foo, foo],
1321 tube(a, a, a^2, 1, a, -2, 2) )$
1323 @figure{draw_enhanced3d7}
1325 @code{implicit} and @code{points} objects with coloring defined by the @code{[f(x,y,z), x, y, z]} model.
1329 enhanced3d = [x-y,x,y,z],
1330 implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015,
1331 x,-1,1,y,-1.2,2.3,z,-1,1)) $
1332 (%i2) m: makelist([random(1.0),random(1.0),random(1.0)],k,1,2000)$
1334 @figure{draw_enhanced3d9}
1337 point_type = filled_circle,
1339 enhanced3d = [u+v-w,u,v,w],
1342 @figure{draw_enhanced3d10}
1344 When points have a chronological nature, model @code{[f(k), k]} is also valid,
1345 being @code{k} an ordering parameter.
1348 (%i1) m:makelist([random(1.0), random(1.0), random(1.0)],k,1,5)$
1350 enhanced3d = [sin(j), j],
1352 point_type = filled_circle,
1353 points_joined = true,
1356 @figure{draw_enhanced3d11}
1358 @opencatbox{Categories:}
1359 @category{Package draw}
1368 @defvr {Graphic option} error_type
1369 Default value: @code{y}
1371 Depending on its value, which can be @code{x}, @code{y}, or @code{xy},
1372 graphic object @code{errors} will draw points with horizontal, vertical,
1373 or both, error bars. When @code{error_type=boxes}, boxes will be drawn
1376 See also @mrefdot{errors}
1382 @defvr {Graphic option} file_name
1383 Default value: @code{"maxima_out"}
1385 This is the name of the file where terminals @code{png}, @code{jpg}, @code{gif},
1386 @code{eps}, @code{eps_color}, @code{pdf}, @code{pdfcairo} and @code{svg}
1387 will save the graphic.
1389 Since this is a global graphics option, its position in the scene description
1390 does not matter. It can be also used as an argument of function @code{draw}.
1395 (%i1) draw2d(file_name = "myfile",
1396 explicit(x^2,x,-1,1),
1400 See also @mrefcomma{terminal} @mrefdot{dimensions_draw}
1402 @opencatbox{Categories:}
1403 @category{Package draw}
1411 @defvr {Graphic option} fill_color
1412 Default value: @code{"red"}
1414 @code{fill_color} specifies the color for filling polygons and
1415 2d @code{explicit} functions.
1417 See @code{color} to learn how colors are specified.
1419 @opencatbox{Categories:}
1420 @category{Package draw}
1428 @anchor{fill_density}
1429 @defvr {Graphic option} fill_density
1432 @code{fill_density} is a number between 0 and 1 that specifies
1433 the intensity of the @code{fill_color} in @code{bars} objects.
1435 See @code{bars} for examples.
1441 @anchor{filled_func}
1442 @defvr {Graphic option} filled_func
1443 Default value: @code{false}
1445 Option @code{filled_func} controls how regions limited by functions
1446 should be filled. When @code{filled_func} is @code{true}, the region
1447 bounded by the function defined with object @code{explicit} and the
1448 bottom of the graphic window is filled with @code{fill_color}. When
1449 @code{filled_func} contains a function expression, then the region bounded
1450 by this function and the function defined with object @code{explicit}
1451 will be filled. By default, explicit functions are not filled.
1453 A useful special case is @code{filled_func=0}, which generates the region
1454 bond by the horizontal axis and the explicit function.
1456 This option affects only the 2d graphic object @mrefdot{explicit}
1460 Region bounded by an @code{explicit} object and the bottom of the
1463 (%i1) draw2d(fill_color = red,
1465 explicit(sin(x),x,0,10) )$
1467 @figure{draw_filledfunc}
1469 Region bounded by an @code{explicit} object and the function
1470 defined by option @code{filled_func}. Note that the variable in
1471 @code{filled_func} must be the same as that used in @code{explicit}.
1473 (%i1) draw2d(fill_color = grey,
1474 filled_func = sin(x),
1475 explicit(-sin(x),x,0,%pi));
1477 @figure{draw_filledfunc2}
1478 See also @mref{fill_color} and @mrefdot{explicit}
1480 @opencatbox{Categories:}
1481 @category{Package draw}
1489 @defvr {Graphic option} font
1490 Default value: @code{""} (empty string)
1492 This option can be used to set the font face to be used by the terminal.
1493 Only one font face and size can be used throughout the plot.
1495 Since this is a global graphics option, its position in the scene description
1498 See also @mrefdot{font_size}
1500 Gnuplot doesn't handle fonts by itself, it leaves this task to the
1501 support libraries of the different terminals, each one with its own
1502 philosophy about it. A brief summary follows:
1507 Uses the normal x11 font server mechanism.
1511 (%i1) draw2d(font = "Arial",
1513 label(["Arial font, size 20",1,1]))$
1518 The windows terminal doesn't support changing of fonts from inside the plot.
1519 Once the plot has been generated, the font can be changed right-clicking on
1520 the menu of the graph window.
1524 The @i{libgd} library uses the font path stored in the environment
1525 variable @env{GDFONTPATH}; in this case, it is only necessary to
1526 set option @code{font} to the font's name. It is also possible to
1527 give the complete path to the font file.
1531 Option @code{font} can be given the complete path to the font file:
1533 (%i1) path: "/usr/share/fonts/truetype/freefont/" $
1534 (%i2) file: "FreeSerifBoldItalic.ttf" $
1536 font = concat(path, file),
1539 label(["FreeSerifBoldItalic font, size 20",1,1]),
1543 If environment variable @env{GDFONTPATH} is set to the
1544 path where font files are allocated, it is possible to
1545 set graphic option @code{font} to the name of the font.
1548 font = "FreeSerifBoldItalic",
1551 label(["FreeSerifBoldItalic font, size 20",1,1]),
1557 Standard Postscript fonts are:@*
1558 @code{"Times-Roman"}, @code{"Times-Italic"}, @code{"Times-Bold"},
1559 @code{"Times-BoldItalic"},@*
1560 @code{"Helvetica"}, @code{"Helvetica-Oblique"}, @code{"Helvetica-Bold"},@*
1561 @code{"Helvetic-BoldOblique"}, @code{"Courier"},
1562 @code{"Courier-Oblique"}, @code{"Courier-Bold"},@*
1563 and @code{"Courier-BoldOblique"}.
1568 font = "Courier-Oblique",
1570 label(["Courier-Oblique font, size 15",1,1]),
1576 Uses same fonts as @i{Postscript}.
1580 Uses same fonts as @i{wxt}.
1584 The @i{pango} library finds fonts via the @code{fontconfig} utility.
1588 Default is @code{"Times-Roman"}.
1591 The gnuplot documentation is an important source of information about terminals and fonts.
1593 @opencatbox{Categories:}
1594 @category{Package draw}
1602 @defvr {Graphic option} font_size
1605 This option can be used to set the font size to be used by the terminal.
1606 Only one font face and size can be used throughout the plot. @code{font_size} is
1607 active only when option @code{font} is not equal to the empty string.
1609 Since this is a global graphics option, its position in the scene description
1612 See also @mrefdot{font}
1614 @opencatbox{Categories:}
1615 @category{Package draw}
1622 @anchor{gnuplot_file_name}
1623 @defvr {Graphic option} gnuplot_file_name
1624 Default value: @code{"maxout_xxx.gnuplot"} with @code{"xxx"}
1625 being a number that is unique to each concurrently-running
1628 This is the name of the file with the necessary commands to
1629 be processed by Gnuplot.
1631 Since this is a global graphics option, its position in the scene description
1632 does not matter. It can be also used as an argument of function @code{draw}.
1638 file_name = "my_file",
1639 gnuplot_file_name = "my_commands_for_gnuplot",
1640 data_file_name = "my_data_for_gnuplot",
1642 explicit(x^2,x,-1,1)) $
1645 See also @mrefdot{data_file_name}
1647 @opencatbox{Categories:}
1648 @category{Package draw}
1656 @defvr {Graphic option} grid
1657 Default value: @code{false}
1659 If @code{grid} is @code{not false}, a grid will be drawn on the @var{xy} plane.
1660 If @code{grid} is assigned true, one grid line per tick of each axis is drawn.
1661 If @code{grid} is assigned a list @code{nx,ny} with @code{[nx,ny] > [0,0]}
1662 instead @code{nx} lines per tick of the x axis and @code{ny} lines per tick of
1663 the y axis are drawn.
1665 Since this is a global graphics option, its position in the scene description
1671 (%i1) draw2d(grid = true,
1672 explicit(exp(u),u,-2,2))$
1677 (%i1) draw2d(grid = [2,2],
1678 explicit(sin(x),x,0,2*%pi))$
1682 @opencatbox{Categories:}
1683 @category{Package draw}
1691 @defvr {Graphic option} head_angle
1694 @code{head_angle} indicates the angle, in degrees, between the arrow heads and
1697 This option is relevant only for @code{vector} objects.
1702 (%i1) draw2d(xrange = [0,10],
1706 vector([1,1],[0,6]),
1708 vector([2,1],[0,6]),
1710 vector([3,1],[0,6]),
1712 vector([4,1],[0,6]),
1714 vector([5,1],[0,6]),
1716 vector([6,1],[0,6]),
1718 vector([7,1],[0,6]),
1720 vector([8,1],[0,6]),
1722 vector([9,1],[0,6]) )$
1724 @figure{draw_head_angle}
1726 See also @mrefcomma{head_both} @mrefcomma{head_length} and @mrefdot{head_type}
1728 @opencatbox{Categories:}
1729 @category{Package draw}
1737 @defvr {Graphic option} head_both
1738 Default value: @code{false}
1740 If @code{head_both} is @code{true}, vectors are plotted with two arrow heads.
1741 If @code{false}, only one arrow is plotted.
1743 This option is relevant only for @code{vector} objects.
1748 (%i1) draw2d(xrange = [0,8],
1751 vector([1,1],[6,0]),
1753 vector([1,7],[6,0]) )$
1755 @figure{draw_head_both}
1757 See also @mrefcomma{head_length} @mrefcomma{head_angle} and @mrefdot{head_type}
1759 @opencatbox{Categories:}
1760 @category{Package draw}
1767 @anchor{head_length}
1768 @defvr {Graphic option} head_length
1771 @code{head_length} indicates, in @var{x}-axis units, the length of arrow heads.
1773 This option is relevant only for @code{vector} objects.
1778 (%i1) draw2d(xrange = [0,12],
1780 vector([0,1],[5,5]),
1782 vector([2,1],[5,5]),
1784 vector([4,1],[5,5]),
1786 vector([6,1],[5,5]))$
1788 @figure{draw_head_length}
1790 See also @mrefcomma{head_both} @mrefcomma{head_angle} and @mrefdot{head_type}
1792 @opencatbox{Categories:}
1793 @category{Package draw}
1803 @defvr {Graphic option} head_type
1804 Default value: @code{filled}
1806 @code{head_type} is used to specify how arrow heads are plotted. Possible
1807 values are: @code{filled} (closed and filled arrow heads), @code{empty}
1808 (closed but not filled arrow heads), and @code{nofilled} (open arrow heads).
1810 This option is relevant only for @code{vector} objects.
1815 (%i1) draw2d(xrange = [0,12],
1818 vector([0,1],[5,5]), /* default type */
1820 vector([3,1],[5,5]),
1821 head_type = 'nofilled,
1822 vector([6,1],[5,5]))$
1824 @figure{draw_head_type}
1826 See also @mrefcomma{head_both} @mrefcomma{head_angle} and @mrefdot{head_length}
1828 @opencatbox{Categories:}
1829 @category{Package draw}
1836 @anchor{interpolate_color}
1837 @defvr {Graphic option} interpolate_color
1838 Default value: @code{false}
1840 This option is relevant only when @code{enhanced3d} is not @code{false}.
1842 When @code{interpolate_color} is @code{false}, surfaces are colored with
1843 homogeneous quadrangles. When @code{true}, color transitions are smoothed
1846 @code{interpolate_color} also accepts a list of two numbers, @code{[m,n]}.
1847 For positive @var{m} and @var{n}, each quadrangle or triangle is interpolated
1848 @var{m} times and @var{n} times in the respective direction. For negative
1849 @var{m} and @var{n}, the interpolation frequency is chosen so that there will be at least
1850 @var{|m|} and @var{|n|} points drawn; you can consider this as a special gridding function.
1851 Zeros, i.e. @code{interpolate_color=[0,0]}, will automatically choose an
1852 optimal number of interpolated surface points.
1854 Also, @code{interpolate_color=true} is equivalent to @code{interpolate_color=[0,0]}.
1858 Color interpolation with explicit functions.
1862 enhanced3d = sin(x*y),
1863 explicit(20*exp(-x^2-y^2)-10, x ,-3, 3, y, -3, 3)) $
1865 @figure{draw_interpolate_color}
1868 interpolate_color = true,
1869 enhanced3d = sin(x*y),
1870 explicit(20*exp(-x^2-y^2)-10, x ,-3, 3, y, -3, 3)) $
1872 @figure{draw_interpolate_color2}
1875 interpolate_color = [-10,0],
1876 enhanced3d = sin(x*y),
1877 explicit(20*exp(-x^2-y^2)-10, x ,-3, 3, y, -3, 3)) $
1879 @figure{draw_interpolate_color3}
1881 Color interpolation with the @code{mesh} graphic object.
1883 Interpolating colors in parametric surfaces can give unexpected results.
1888 mesh([[1,1,3], [7,3,1],[12,-2,4],[15,0,5]],
1889 [[2,7,8], [4,3,1],[10,5,8], [12,7,1]],
1890 [[-2,11,10],[6,9,5],[6,15,1], [20,15,2]])) $
1892 @figure{draw_interpolate_color4}
1896 interpolate_color = true,
1897 mesh([[1,1,3], [7,3,1],[12,-2,4],[15,0,5]],
1898 [[2,7,8], [4,3,1],[10,5,8], [12,7,1]],
1899 [[-2,11,10],[6,9,5],[6,15,1], [20,15,2]])) $
1901 @figure{draw_interpolate_color5}
1905 interpolate_color = true,
1907 mesh([[1,1,3], [7,3,1],[12,-2,4],[15,0,5]],
1908 [[2,7,8], [4,3,1],[10,5,8], [12,7,1]],
1909 [[-2,11,10],[6,9,5],[6,15,1], [20,15,2]])) $
1911 @figure{draw_interpolate_color6}
1913 See also @mrefdot{enhanced3d}
1915 @opencatbox{Categories:}
1916 @category{Package draw}
1924 @defvr {Graphic option} ip_grid
1925 Default value: @code{[50, 50]}
1927 @code{ip_grid} sets the grid for the first sampling in implicit plots.
1929 This option is relevant only for @code{implicit} objects.
1931 @opencatbox{Categories:}
1932 @category{Package draw}
1940 @defvr {Graphic option} ip_grid_in
1941 Default value: @code{[5, 5]}
1943 @code{ip_grid_in} sets the grid for the second sampling in implicit plots.
1945 This option is relevant only for @code{implicit} objects.
1947 @opencatbox{Categories:}
1948 @category{Package draw}
1956 @defvr {Graphic option} key
1957 Default value: @code{""} (empty string)
1959 @code{key} is the name of a function in the legend. If @code{key} is an
1960 empty string, no key is assigned to the function.
1962 This option affects the following graphic objects:
1965 @code{gr2d}: @mrefcomma{points} @mrefcomma{polygon} @mrefcomma{rectangle}
1966 @mrefcomma{ellipse} @mrefcomma{vector} @mrefcomma{explicit} @mrefcomma{implicit}
1967 @mref{parametric} and @mrefdot{polar}
1970 @code{gr3d}: @mrefcomma{points} @mrefcomma{explicit} @mref{parametric}
1971 and @mrefdot{parametric_surface}
1977 (%i1) draw2d(key = "Sinus",
1978 explicit(sin(x),x,0,10),
1981 explicit(cos(x),x,0,10) )$
1984 @opencatbox{Categories:}
1985 @category{Package draw}
1994 @defvr {Graphic option} key_pos
1995 Default value: @code{""} (empty string)
1997 @code{key_pos} defines at which position the legend will be drawn. If @code{key} is an
1998 empty string, @code{"top_right"} is used.
1999 Available position specifiers are: @code{top_left}, @code{top_center}, @code{top_right},
2000 @code{center_left}, @code{center}, @code{center_right},
2001 @code{bottom_left}, @code{bottom_center}, and @code{bottom_right}.
2003 Since this is a global graphics option, its position in the scene description
2012 explicit(x, x,0,10),
2015 explicit(x^2,x,0,10))$
2019 explicit(x+y,x,0,10,y,0,10),
2022 explicit(x^2+y^2,x,0,10,y,0,10))$
2024 @figure{draw_key_pos}
2026 @opencatbox{Categories:}
2027 @category{Package draw}
2034 @anchor{label_alignment}
2035 @defvr {Graphic option} label_alignment
2036 Default value: @code{center}
2038 @code{label_alignment} is used to specify where to write labels with
2039 respect to the given coordinates. Possible values are: @code{center},
2040 @code{left}, and @code{right}.
2042 This option is relevant only for @code{label} objects.
2047 (%i1) draw2d(xrange = [0,10],
2049 points_joined = true,
2050 points([[5,0],[5,10]]),
2052 label(["Centered alignment (default)",5,2]),
2053 label_alignment = 'left,
2054 label(["Left alignment",5,5]),
2055 label_alignment = 'right,
2056 label(["Right alignment",5,8]))$
2058 @figure{draw_label_alignment}
2060 See also @mrefcomma{label_orientation} and @code{color}
2062 @opencatbox{Categories:}
2063 @category{Package draw}
2070 @anchor{label_orientation}
2071 @defvr {Graphic option} label_orientation
2072 Default value: @code{horizontal}
2074 @code{label_orientation} is used to specify orientation of labels.
2075 Possible values are: @code{horizontal}, and @code{vertical}.
2077 This option is relevant only for @code{label} objects.
2081 In this example, a dummy point is added to get an image.
2082 Package @code{draw} needs always data to draw an scene.
2084 (%i1) draw2d(xrange = [0,10],
2089 label(["Horizontal orientation (default)",5,2]),
2090 label_orientation = 'vertical,
2092 label(["Vertical orientation",1,5]))$
2094 @figure{draw_label_orientation}
2096 See also @mref{label_alignment} and @code{color}
2098 @opencatbox{Categories:}
2099 @category{Package draw}
2107 @defvr {Graphic option} line_type
2108 Default value: @code{solid}
2110 @code{line_type} indicates how lines are displayed; possible values are
2111 @code{solid} and @code{dots}, both available in all terminals, and
2112 @code{dashes}, @code{short_dashes}, @code{short_long_dashes}, @code{short_short_long_dashes},
2113 and @code{dot_dash}, which are not available in @code{png}, @code{jpg}, and @code{gif} terminals.
2115 This option affects the following graphic objects:
2118 @code{gr2d}: @mrefcomma{points} @mrefcomma{polygon} @mrefcomma{rectangle}
2119 @mrefcomma{ellipse} @mrefcomma{vector} @mrefcomma{explicit} @mrefcomma{implicit}
2120 @mref{parametric} and @mrefdot{polar}
2123 @code{gr3d}: @mrefcomma{points} @mrefcomma{explicit} @mref{parametric} and @mrefdot{parametric_surface}
2129 (%i1) draw2d(line_type = dots,
2130 explicit(1 + x^2,x,-1,1),
2131 line_type = solid, /* default */
2132 explicit(2 + x^2,x,-1,1))$
2134 @figure{draw_line_type}
2136 See also @mrefdot{line_width}
2138 @opencatbox{Categories:}
2139 @category{Package draw}
2147 @defvr {Graphic option} line_width
2150 @code{line_width} is the width of plotted lines.
2151 Its value must be a positive number.
2153 This option affects the following graphic objects:
2156 @code{gr2d}: @mrefcomma{points} @mrefcomma{polygon} @mrefcomma{rectangle}
2157 @mrefcomma{ellipse} @mrefcomma{vector} @mrefcomma{explicit} @mrefcomma{implicit}
2158 @mref{parametric} and @mrefdot{polar}
2161 @code{gr3d}: @mref{points} and @mrefdot{parametric}
2167 (%i1) draw2d(explicit(x^2,x,-1,1), /* default width */
2169 explicit(1 + x^2,x,-1,1),
2171 explicit(2 + x^2,x,-1,1))$
2173 @figure{draw_line_width}
2175 See also @mrefdot{line_type}
2177 @opencatbox{Categories:}
2178 @category{Package draw}
2186 @defvr {Graphic option} logcb
2187 Default value: @code{false}
2189 If @mref{logcb} is @code{true}, the tics in the colorbox will be drawn in the
2192 When @code{enhanced3d} or @code{colorbox} is @code{false}, option @code{logcb} has
2195 Since this is a global graphics option, its position in the scene description
2206 palette = [-15,24,-9],
2207 explicit(exp(x^2-y^2), x,-2,2,y,-2,2)) $
2211 See also @mrefcomma{enhanced3d} @mref{colorbox} and @mrefdot{cbrange}
2213 @opencatbox{Categories:}
2214 @category{Package draw}
2222 @defvr {Graphic option} logx
2223 Default value: @code{false}
2225 If @code{logx} is @code{true}, the @var{x} axis will be drawn in the
2228 Since this is a global graphics option, its position in the scene description
2229 does not matter, with the exception that it should be written before any
2230 2D @code{explicit} object, so that @code{draw} can produce a better plot.
2235 (%i1) draw2d(logx = true,
2236 explicit(log(x),x,0.01,5))$
2239 See also @mrefcomma{logy} @mrefcomma{logx_secondary} @mrefcomma{logy_secondary} and @mrefdot{logz}
2241 @opencatbox{Categories:}
2242 @category{Package draw}
2249 @anchor{logx_secondary}
2250 @defvr {Graphic option} logx_secondary
2251 Default value: @code{false}
2253 If @code{logx_secondary} is @code{true}, the secondary @var{x} axis
2254 will be drawn in the logarithmic scale.
2256 This option is relevant only for 2d scenes.
2258 Since this is a global graphics option, its position in the scene description
2266 key="x^2, linear scale",
2268 explicit(x^2,x,1,100),
2269 xaxis_secondary = true,
2270 xtics_secondary = true,
2271 logx_secondary = true,
2272 key = "x^2, logarithmic x scale",
2274 explicit(x^2,x,1,100) )$
2276 @figure{draw_logx_secondary}
2278 See also @mrefcomma{logx_draw} @mrefcomma{logy_draw} @mrefcomma{logy_secondary} and @mrefdot{logz}
2280 @opencatbox{Categories:}
2281 @category{Package draw}
2289 @defvr {Graphic option} logy
2290 Default value: @code{false}
2292 If @code{logy} is @code{true}, the @var{y} axis will be drawn in the
2295 Since this is a global graphics option, its position in the scene description
2301 (%i1) draw2d(logy = true,
2302 explicit(exp(x),x,0,5))$
2305 See also @mrefcomma{logx_draw} @mrefcomma{logx_secondary} @mrefcomma{logy_secondary} and @mrefdot{logz}
2307 @opencatbox{Categories:}
2308 @category{Package draw}
2315 @anchor{logy_secondary}
2316 @defvr {Graphic option} logy_secondary
2317 Default value: @code{false}
2319 If @code{logy_secondary} is @code{true}, the secondary @var{y} axis
2320 will be drawn in the logarithmic scale.
2322 This option is relevant only for 2d scenes.
2324 Since this is a global graphics option, its position in the scene description
2332 key="x^2, linear scale",
2334 explicit(x^2,x,1,100),
2335 yaxis_secondary = true,
2336 ytics_secondary = true,
2337 logy_secondary = true,
2338 key = "x^2, logarithmic y scale",
2340 explicit(x^2,x,1,100) )$
2343 See also @mrefcomma{logx_draw} @mrefcomma{logy_draw} @mrefcomma{logx_secondary} and @mrefdot{logz}
2345 @opencatbox{Categories:}
2346 @category{Package draw}
2354 @defvr {Graphic option} logz
2355 Default value: @code{false}
2357 If @code{logz} is @code{true}, the @var{z} axis will be drawn in the
2360 Since this is a global graphics option, its position in the scene description
2366 (%i1) draw3d(logz = true,
2367 explicit(exp(u^2+v^2),u,-2,2,v,-2,2))$
2370 See also @mref{logx_draw} and @mrefdot{logy_draw}
2372 @opencatbox{Categories:}
2373 @category{Package draw}
2380 @defvr {Graphic option} nticks
2383 In 2d, @code{nticks} gives the initial number of points used by the
2384 adaptive plotting routine for explicit objects. It is also the
2385 number of points that will be shown in parametric and polar curves.
2387 This option affects the following graphic objects:
2390 @code{gr2d}: @mrefcomma{ellipse} @mrefcomma{explicit} @mref{parametric} and @mrefdot{polar}
2393 @code{gr3d}: @mrefdot{parametric}
2396 See also @code{adapt_depth}
2401 (%i1) draw2d(transparent = true,
2402 ellipse(0,0,4,2,0,180),
2404 ellipse(0,0,4,2,180,180) )$
2406 @figure{draw_nticks}
2408 @opencatbox{Categories:}
2409 @category{Package draw}
2416 @anchor{palette_draw}
2417 @defvr {Graphic option} palette
2418 Default value: @code{color}
2420 @code{palette} indicates how to map gray levels onto color components.
2421 It works together with option @code{enhanced3d} in 3D graphics,
2422 who associates every point of a surfaces to a real number or gray level.
2423 It also works with gray images. With @code{palette}, levels are transformed into colors.
2425 There are two ways for defining these transformations.
2427 First, @code{palette} can be a vector of length three with components
2428 ranging from -36 to +36; each value is an index for a formula mapping the levels
2429 onto red, green and blue colors, respectively:
2433 6: x^4 7: sqrt(x) 8: sqrt(sqrt(x))
2434 9: sin(90x) 10: cos(90x) 11: |x-0.5|
2435 12: (2x-1)^2 13: sin(180x) 14: |cos(180x)|
2436 15: sin(360x) 16: cos(360x) 17: |sin(360x)|
2437 18: |cos(360x)| 19: |sin(720x)| 20: |cos(720x)|
2438 21: 3x 22: 3x-1 23: 3x-2
2439 24: |3x-1| 25: |3x-2| 26: (3x-1)/2
2440 27: (3x-2)/2 28: |(3x-1)/2| 29: |(3x-2)/2|
2441 30: x/0.32-0.78125 31: 2*x-0.84 32: 4x;1;-2x+1.84;x/0.08-11.5
2442 33: |2*x - 0.5| 34: 2*x 35: 2*x - 0.5
2445 negative numbers mean negative colour component.
2446 @code{palette = gray} and @code{palette = color} are short cuts for
2447 @code{palette = [3,3,3]} and @code{palette = [7,5,15]}, respectively.
2449 Second, @code{palette} can be a user defined lookup table. In this case,
2450 the format for building a lookup table of length @code{n} is
2451 @code{palette=[color_1, color_2, ..., color_n]}, where @code{color_i} is
2452 a well formed color (see option @code{color}) such that @code{color_1} is
2453 assigned to the lowest gray level and @code{color_n} to the highest. The rest
2454 of colors are interpolated.
2456 Since this is a global graphics option, its position in the scene description
2461 It works together with option @code{enhanced3d} in 3D graphics.
2465 enhanced3d = [z-x+2*y,x,y,z],
2466 palette = [32, -8, 17],
2467 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$
2469 @figure{draw_palette}
2471 It also works with gray images.
2476 makelist(makelist(random(200),i,1,30),i,1,30))$
2477 (%i2) /* palette = color, default */
2478 draw2d(image(im,0,0,30,30))$
2479 (%i3) draw2d(palette = gray, image(im,0,0,30,30))$
2480 (%i4) draw2d(palette = [15,20,-4],
2482 image(im,0,0,30,30))$
2484 @figure{draw_palette2}
2486 @code{palette} can be a user defined lookup table.
2487 In this example, low values of @code{x} are colored
2488 in red, and higher values in yellow.
2492 palette = [red, blue, yellow],
2494 explicit(x^2+y^2,x,-1,1,y,-1,1)) $
2496 @figure{draw_palette3}
2498 See also @mref{colorbox} and @mrefdot{enhanced3d}
2500 @opencatbox{Categories:}
2501 @category{Package draw}
2509 @defvr {Graphic option} point_size
2512 @code{point_size} sets the size for plotted points. It must be a
2513 non negative number.
2515 This option has no effect when graphic option @code{point_type} is
2518 This option affects the following graphic objects:
2521 @code{gr2d}: @mrefdot{points}
2524 @code{gr3d}: @mrefdot{points}
2530 (%i1) draw2d(points(makelist([random(20),random(50)],k,1,10)),
2532 points(makelist(k,k,1,20),makelist(random(30),k,1,20)))$
2534 @figure{draw_point_size}
2536 @opencatbox{Categories:}
2537 @category{Package draw}
2544 @anchor{point_type_draw}
2545 @defvr {Graphic option} point_type
2548 @code{point_type} indicates how isolated points are displayed; the value of this
2549 option can be any integer index greater or equal than -1, or the name of
2550 a point style: @code{$none} (-1), @code{dot} (0), @code{plus} (1), @code{multiply} (2),
2551 @code{asterisk} (3), @code{square} (4), @code{filled_square} (5), @code{circle} (6),
2552 @code{filled_circle} (7), @code{up_triangle} (8), @code{filled_up_triangle} (9),
2553 @code{down_triangle} (10), @code{filled_down_triangle} (11), @code{diamant} (12) and
2554 @code{filled_diamant} (13).
2556 This option affects the following graphic objects:
2559 @code{gr2d}: @mrefdot{points}
2562 @code{gr3d}: @mrefdot{points}
2568 (%i1) draw2d(xrange = [0,10],
2571 point_type = diamant,
2572 points([[1,1],[5,1],[9,1]]),
2573 point_type = filled_down_triangle,
2574 points([[1,2],[5,2],[9,2]]),
2575 point_type = asterisk,
2576 points([[1,3],[5,3],[9,3]]),
2577 point_type = filled_diamant,
2578 points([[1,4],[5,4],[9,4]]),
2580 points([[1,5],[5,5],[9,5]]),
2582 points([[1,6],[5,6],[9,6]]),
2583 point_type = filled_circle,
2584 points([[1,7],[5,7],[9,7]]),
2586 points([[1,8],[5,8],[9,8]]),
2587 point_type = filled_diamant,
2588 points([[1,9],[5,9],[9,9]]) )$
2590 @figure{draw_point_type}
2592 @opencatbox{Categories:}
2593 @category{Package draw}
2600 @anchor{points_joined}
2601 @defvr {Graphic option} points_joined
2602 Default value: @code{false}
2604 When @code{points_joined} is @code{true}, points are joined by lines; when @code{false},
2605 isolated points are drawn. A third possible value for this graphic option is
2606 @code{impulses}; in such case, vertical segments are drawn from points to the x-axis (2D)
2607 or to the xy-plane (3D).
2609 This option affects the following graphic objects:
2612 @code{gr2d}: @mrefdot{points}
2615 @code{gr3d}: @mrefdot{points}
2621 (%i1) draw2d(xrange = [0,10],
2624 point_type = up_triangle,
2626 points([[1,1],[5,1],[9,1]]),
2627 points_joined = true,
2628 point_type = square,
2630 points([[1,2],[5,2],[9,2]]),
2631 point_type = circle,
2634 points([[1,3],[5,3],[9,3]]) )$
2636 @figure{draw_points_joined}
2638 @opencatbox{Categories:}
2639 @category{Package draw}
2646 @anchor{proportional_axes}
2647 @defvr {Graphic option} proportional_axes
2648 Default value: @code{none}
2650 When @code{proportional_axes} is equal to @code{xy} or @code{xyz},
2651 the aspect ratio of the axis units will be set to 1:1 resulting in a 2D or 3D
2652 scene that will be drawn with axes proportional to their relative lengths.
2654 Since this is a global graphics option, its position in the scene description
2657 This option works with Gnuplot version 4.2.6 or greater.
2665 ellipse(0,0,1,1,0,360),
2669 ellipse(0,0,2,1/2,0,360),
2670 proportional_axes = 'xy) $
2672 @figure{draw_proportional_axis}
2679 gr2d(proportional_axes = 'xy,
2680 explicit(x^2,x,0,1)),
2681 gr2d(explicit(x^2,x,0,1),
2684 proportional_axes='xy),
2685 gr2d(explicit(x^2,x,0,1)))$
2687 @figure{draw_proportional_axis2}
2689 @opencatbox{Categories:}
2690 @category{Package draw}
2697 @anchor{surface_hide}
2698 @defvr {Graphic option} surface_hide
2699 Default value: @code{false}
2701 If @code{surface_hide} is @code{true}, hidden parts are not plotted in 3d surfaces.
2703 Since this is a global graphics option, its position in the scene description
2709 (%i1) draw(columns=2,
2710 gr3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)),
2711 gr3d(surface_hide = true,
2712 explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)) )$
2714 @figure{draw_surface_hide}
2716 @opencatbox{Categories:}
2717 @category{Package draw}
2725 @defvr {Graphic option} terminal
2726 Default value: @code{screen}
2728 Selects the terminal to be used by Gnuplot; possible values are:
2729 @code{screen} (default), @code{png}, @code{pngcairo}, @code{jpg}, @code{gif},
2730 @code{eps}, @code{eps_color}, @code{epslatex}, @code{epslatex_standalone},
2731 @code{svg}, @code{canvas}, @code{dumb}, @code{dumb_file}, @code{pdf}, @code{pdfcairo},
2732 @code{wxt}, @code{animated_gif}, @code{multipage_pdfcairo}, @code{multipage_pdf},
2733 @code{multipage_eps}, @code{multipage_eps_color}, and @code{aquaterm}.
2735 Terminals @code{screen}, @code{wxt}, @code{windows} and @code{aquaterm} can
2736 be also defined as a list
2737 with two elements: the name of the terminal itself and a non negative integer number.
2738 In this form, multiple windows can be opened at the same time, each with its
2739 corresponding number. This feature does not work in Windows platforms.
2741 Since this is a global graphics option, its position in the scene description
2742 does not matter. It can be also used as an argument of function @code{draw}.
2744 N.B. pdfcairo requires Gnuplot 4.3 or newer.
2745 @code{pdf} requires Gnuplot to be compiled with the option @code{--enable-pdf} and libpdf must
2746 be installed. The pdf library is available from: @url{http://www.pdflib.com/en/download/pdflib-family/pdflib-lite/}
2751 (%i1) /* screen terminal (default) */
2752 draw2d(explicit(x^2,x,-1,1))$
2753 (%i2) /* png file */
2754 draw2d(terminal = 'png,
2755 explicit(x^2,x,-1,1))$
2756 (%i3) /* jpg file */
2757 draw2d(terminal = 'jpg,
2758 dimensions = [300,300],
2759 explicit(x^2,x,-1,1))$
2760 (%i4) /* eps file */
2761 draw2d(file_name = "myfile",
2762 explicit(x^2,x,-1,1),
2764 (%i5) /* pdf file */
2765 draw2d(file_name = "mypdf",
2766 dimensions = 100*[12.0,8.0],
2767 explicit(x^2,x,-1,1),
2769 (%i6) /* wxwidgets window */
2770 draw2d(explicit(x^2,x,-1,1),
2776 (%i1) draw2d(explicit(x^5,x,-2,2), terminal=[screen, 3])$
2777 (%i2) draw2d(explicit(x^2,x,-2,2), terminal=[screen, 0])$
2780 An animated gif file.
2785 terminal = 'animated_gif,
2786 gr2d(explicit(x^2,x,-1,1)),
2787 gr2d(explicit(x^3,x,-1,1)),
2788 gr2d(explicit(x^4,x,-1,1)));
2789 End of animation sequence
2790 (%o1) [gr2d(explicit), gr2d(explicit), gr2d(explicit)]
2793 Option @code{delay} is only active in animated gif's; it is ignored in
2796 Multipage output in eps format.
2799 file_name = "parabol",
2800 terminal = multipage_eps,
2801 dimensions = 100*[10,10],
2802 gr2d(explicit(x^2,x,-1,1)),
2803 gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1))) $
2806 See also @mrefcomma{file_name} @mref{dimensions_draw} and @mrefdot{delay}
2808 @opencatbox{Categories:}
2809 @category{Package draw}
2817 @defvr {Graphic option} title
2818 Default value: @code{""} (empty string)
2820 Option @code{title}, a string, is the main title for the scene.
2821 By default, no title is written.
2823 Since this is a global graphics option, its position in the scene description
2829 (%i1) draw2d(explicit(exp(u),u,-2,2),
2830 title = "Exponential function")$
2834 @opencatbox{Categories:}
2835 @category{Package draw}
2843 @defvr {Graphic option} transform
2844 Default value: @code{none}
2846 If @code{transform} is @code{none}, the space is not transformed and
2847 graphic objects are drawn as defined. When a space transformation is
2848 desired, a list must be assigned to option @code{transform}. In case of
2849 a 2D scene, the list takes the form @code{[f1(x,y), f2(x,y), x, y]}.
2850 In case of a 3D scene, the list is of the form
2851 @code{[f1(x,y,z), f2(x,y,z), f3(x,y,z), x, y, z]}.
2853 The names of the variables defined in the lists may be different to those
2854 used in the definitions of the graphic objects.
2864 proportional_axes = 'xy,
2866 triangle([3,2],[7,2],[5,5]),
2868 fill_color = yellow,
2869 transform = [cos(th)*x - sin(th)*y,
2870 sin(th)*x + cos(th)*y, x, y],
2871 triangle([3,2],[7,2],[5,5]) )$
2873 @figure{draw_transform}
2880 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3),
2881 transform = [x+10,y+10,z+10,x,y,z],
2883 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3) )$
2886 @opencatbox{Categories:}
2887 @category{Package draw}
2893 @anchor{transparent}
2894 @defvr {Graphic option} transparent
2895 Default value: @code{false}
2897 If @code{transparent} is @code{false}, interior regions of polygons are
2898 filled according to @code{fill_color}.
2900 This option affects the following graphic objects:
2903 @code{gr2d}: @mrefcomma{polygon} @mref{rectangle} and @mrefdot{ellipse}
2909 (%i1) draw2d(polygon([[3,2],[7,2],[5,5]]),
2912 polygon([[5,2],[9,2],[7,5]]) )$
2914 @figure{draw_transparent}
2916 @opencatbox{Categories:}
2917 @category{Package draw}
2924 @anchor{unit_vectors}
2925 @defvr {Graphic option} unit_vectors
2926 Default value: @code{false}
2928 If @code{unit_vectors} is @code{true}, vectors are plotted with module 1.
2929 This is useful for plotting vector fields. If @code{unit_vectors} is @code{false},
2930 vectors are plotted with its original length.
2932 This option is relevant only for @code{vector} objects.
2937 (%i1) draw2d(xrange = [-1,6],
2940 vector([0,0],[5,2]),
2941 unit_vectors = true,
2943 vector([0,3],[5,2]))$
2945 @figure{draw_unit_vectors}
2947 @opencatbox{Categories:}
2948 @category{Package draw}
2955 @anchor{user_preamble}
2956 @defvr {Graphic option} user_preamble
2957 Default value: @code{""} (empty string)
2959 Expert Gnuplot users can make use of this option to fine tune Gnuplot's
2960 behaviour by writing settings to be sent before the @code{plot} or @code{splot}
2963 The value of this option must be a string or a list of strings (one per line).
2965 Since this is a global graphics option, its position in the scene description
2970 Tell Gnuplot to draw axes and grid on top of graphics objects,
2973 xaxis =true, xaxis_type=solid,
2974 yaxis =true, yaxis_type=solid,
2975 user_preamble="set grid front",
2976 region(x^2+y^2<1 ,x,-1.5,1.5,y,-1.5,1.5))$
2978 @figure{draw_user_preamble}
2980 Tell gnuplot to draw all contour lines in black
2985 surface_hide=true,enhanced3d=true,wired_surface=true,
2987 user_preamble="set for [i=1:8] linetype i dashtype i linecolor 0",
2988 explicit(sin(x)*cos(y),x,1,10,y,1,10)
2991 @figure{draw_user_preamble2}
2993 @opencatbox{Categories:}
2994 @category{Package draw}
3003 @defvr {Graphic option} view
3004 Default value: @code{[60,30]}
3006 A pair of angles, measured in degrees, indicating the view direction in a
3007 3D scene. The first angle is the vertical rotation around the @var{x} axis, in
3008 the range @math{[0, 360]}. The second one is the horizontal rotation around
3009 the @var{z} axis, in the range @math{[0, 360]}.
3011 If option @code{view} is given the value @code{map}, the view direction is set
3012 to be perpendicular to the xy-plane.
3014 Since this is a global graphics option, its position in the scene description
3020 (%i1) draw3d(view = [170, 50],
3022 explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$
3026 (%i2) draw3d(view = map,
3028 explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$
3032 @opencatbox{Categories:}
3033 @category{Package draw}
3041 @anchor{wired_surface}
3042 @defvr {Graphic option} wired_surface
3043 Default value: @code{false}
3045 Indicates whether 3D surfaces in @code{enhanced3d} mode show the grid joining
3048 Since this is a global graphics option, its position in the scene description
3055 enhanced3d = [sin(x),x,y],
3056 wired_surface = true,
3057 explicit(x^2+y^2,x,-1,1,y,-1,1)) $
3059 @figure{draw_wired_surface}
3061 @opencatbox{Categories:}
3062 @category{Package draw}
3071 @defvr {Graphic option} x_voxel
3074 @code{x_voxel} is the number of voxels in the x direction to
3075 be used by the @i{marching cubes algorithm} implemented
3076 by the 3d @code{implicit} object. It is also used by graphic
3077 object @mrefdot{region}
3079 @opencatbox{Categories:}
3080 @category{Package draw}
3089 @defvr {Graphic option} xaxis
3090 Default value: @code{false}
3092 If @code{xaxis} is @code{true}, the @var{x} axis is drawn.
3094 Since this is a global graphics option, its position in the scene description
3100 (%i1) draw2d(explicit(x^3,x,-1,1),
3102 xaxis_color = blue)$
3106 See also @mrefcomma{xaxis_width} @mref{xaxis_type} and @mrefdot{xaxis_color}
3108 @opencatbox{Categories:}
3109 @category{Package draw}
3117 @anchor{xaxis_color}
3118 @defvr {Graphic option} xaxis_color
3119 Default value: @code{"black"}
3121 @code{xaxis_color} specifies the color for the @var{x} axis. See
3122 @code{color} to know how colors are defined.
3124 Since this is a global graphics option, its position in the scene description
3130 (%i1) draw2d(explicit(x^3,x,-1,1),
3135 See also @mrefcomma{xaxis} @mref{xaxis_width} and @mrefdot{xaxis_type}
3137 @opencatbox{Categories:}
3138 @category{Package draw}
3145 @anchor{xaxis_secondary}
3146 @defvr {Graphic option} xaxis_secondary
3147 Default value: @code{false}
3149 If @code{xaxis_secondary} is @code{true}, function values can be plotted with
3150 respect to the second @var{x} axis, which will be drawn on top of the scene.
3152 Note that this is a local graphics option which only affects to 2d plots.
3158 key = "Bottom x-axis",
3159 explicit(x+1,x,1,2),
3161 key = "Above x-axis",
3162 xtics_secondary = true,
3163 xaxis_secondary = true,
3164 explicit(x^2,x,-1,1)) $
3166 @figure{draw_xaxis_secondary}
3168 See also @mrefcomma{xrange_secondary} @mrefcomma{xtics_secondary} @mrefcomma{xtics_rotate_secondary}
3169 @code{xtics_axis_secondary} and @mrefdot{xaxis_secondary}
3170 @c TODO: Document xtics_axis_secondary
3171 @opencatbox{Categories:}
3172 @category{Package draw}
3181 @defvr {Graphic option} xaxis_type
3182 Default value: @code{dots}
3184 @code{xaxis_type} indicates how the @var{x} axis is displayed;
3185 possible values are @code{solid} and @code{dots}
3187 Since this is a global graphics option, its position in the scene description
3193 (%i1) draw2d(explicit(x^3,x,-1,1),
3195 xaxis_type = solid)$
3198 See also @mrefcomma{xaxis} @mref{xaxis_width} and @mrefdot{xaxis_color}
3200 @opencatbox{Categories:}
3201 @category{Package draw}
3208 @anchor{xaxis_width}
3209 @defvr {Graphic option} xaxis_width
3212 @code{xaxis_width} is the width of the @var{x} axis.
3213 Its value must be a positive number.
3215 Since this is a global graphics option, its position in the scene description
3221 (%i1) draw2d(explicit(x^3,x,-1,1),
3226 See also @mrefcomma{xaxis} @mref{xaxis_type} and @mrefdot{xaxis_color}
3228 @opencatbox{Categories:}
3229 @category{Package draw}
3236 @anchor{xlabel_draw}
3237 @defvr {Graphic option} xlabel
3238 Default value: @code{""}
3240 Option @code{xlabel}, a string, is the label for the @var{x} axis.
3241 By default, the axis is labeled with string @code{"x"}.
3243 Since this is a global graphics option, its position in the scene description
3249 (%i1) draw2d(xlabel = "Time",
3250 explicit(exp(u),u,-2,2),
3251 ylabel = "Population")$
3254 See also @mrefcomma{xlabel_secondary} @mrefcomma{ylabel} @mref{ylabel_secondary} and @mrefdot{zlabel_draw}
3256 @opencatbox{Categories:}
3257 @category{Package draw}
3264 @anchor{xlabel_secondary}
3265 @defvr {Graphic option} xlabel_secondary
3266 Default value: @code{""} (empty string)
3268 Option @code{xlabel_secondary}, a string, is the label for the secondary @var{x} axis.
3269 By default, no label is written.
3271 Since this is a global graphics option, its position in the scene description
3278 xaxis_secondary=true,yaxis_secondary=true,
3279 xtics_secondary=true,ytics_secondary=true,
3280 xlabel_secondary="t[s]",
3281 ylabel_secondary="U[V]",
3282 explicit(sin(t),t,0,10) )$
3284 @figure{draw_ylabel_secondary}
3286 See also @mrefcomma{xlabel_draw} @mrefcomma{ylabel_draw} @mref{ylabel_secondary} and @mrefdot{zlabel_draw}
3288 @opencatbox{Categories:}
3289 @category{Package draw}
3297 @defvr {Graphic option} xrange
3298 Default value: @code{auto}
3300 If @code{xrange} is @code{auto}, the range for the @var{x} coordinate is
3301 computed automatically.
3303 If the user wants a specific interval for @var{x}, it must be given as a
3304 Maxima list, as in @code{xrange=[-2, 3]}.
3306 Since this is a global graphics option, its position in the scene description
3312 (%i1) draw2d(xrange = [-3,5],
3313 explicit(x^2,x,-1,1))$
3316 See also @mref{yrange} and @mrefdot{zrange}
3318 @opencatbox{Categories:}
3319 @category{Package draw}
3326 @anchor{xrange_secondary}
3327 @defvr {Graphic option} xrange_secondary
3328 Default value: @code{auto}
3330 If @code{xrange_secondary} is @code{auto}, the range for the second @var{x} axis is
3331 computed automatically.
3333 If the user wants a specific interval for the second @var{x} axis, it must be given as a
3334 Maxima list, as in @code{xrange_secondary=[-2, 3]}.
3336 Since this is a global graphics option, its position in the scene description
3339 See also @mrefcomma{xrange} @mrefcomma{yrange} @mref{zrange} and @mrefdot{yrange_secondary}
3341 @opencatbox{Categories:}
3342 @category{Package draw}
3350 @defvr {Graphic option} xtics
3351 Default value: @code{true}
3353 This graphic option controls the way tic marks are drawn on the @var{x} axis.
3357 When option @code{xtics} is bounded to symbol @var{true}, tic marks are
3358 drawn automatically.
3361 When option @code{xtics} is bounded to symbol @var{false}, tic marks are
3365 When option @code{xtics} is bounded to a positive number, this is the distance
3366 between two consecutive tic marks.
3369 When option @code{xtics} is bounded to a list of length three of the
3370 form @code{[start,incr,end]}, tic marks are plotted from @code{start}
3371 to @code{end} at intervals of length @code{incr}.
3374 When option @code{xtics} is bounded to a set of numbers of the
3375 form @code{@{n1, n2, ...@}}, tic marks are plotted at values @code{n1},
3379 When option @code{xtics} is bounded to a set of pairs of the
3380 form @code{@{["label1", n1], ["label2", n2], ...@}}, tic marks corresponding to values @code{n1},
3381 @code{n2}, ... are labeled with @code{"label1"}, @code{"label2"}, ..., respectively.
3384 Since this is a global graphics option, its position in the scene description
3391 (%i1) draw2d(xtics = 'false,
3392 explicit(x^3,x,-1,1) )$
3395 Tics every 1/4 units.
3397 (%i1) draw2d(xtics = 1/4,
3398 explicit(x^3,x,-1,1) )$
3401 Tics from -3/4 to 3/4 in steps of 1/8.
3403 (%i1) draw2d(xtics = [-3/4,1/8,3/4],
3404 explicit(x^3,x,-1,1) )$
3407 Tics at points -1/2, -1/4 and 3/4.
3409 (%i1) draw2d(xtics = @{-1/2,-1/4,3/4@},
3410 explicit(x^3,x,-1,1) )$
3415 (%i1) draw2d(xtics = @{["High",0.75],["Medium",0],["Low",-0.75]@},
3416 explicit(x^3,x,-1,1) )$
3419 See also @mrefcomma{ytics_draw} and @mrefdot{ztics_draw}
3421 @opencatbox{Categories:}
3422 @category{Package draw}
3430 @defvr {Graphic option} xtics_axis
3431 Default value: @code{false}
3433 If @code{xtics_axis} is @code{true}, tic marks and their labels are plotted just
3434 along the @var{x} axis, if it is @code{false} tics are plotted on the border.
3436 Since this is a global graphics option, its position in the scene description
3439 @opencatbox{Categories:}
3440 @category{Package draw}
3447 @anchor{xtics_rotate}
3448 @defvr {Graphic option} xtics_rotate
3449 Default value: @code{false}
3451 If @code{xtics_rotate} is @code{true}, tic marks on the @var{x} axis are rotated
3454 Since this is a global graphics option, its position in the scene description
3457 @opencatbox{Categories:}
3458 @category{Package draw}
3464 @anchor{xtics_rotate_secondary}
3465 @defvr {Graphic option} xtics_rotate_secondary
3466 Default value: @code{false}
3468 If @code{xtics_rotate_secondary} is @code{true}, tic marks on the secondary @var{x} axis are rotated
3471 Since this is a global graphics option, its position in the scene description
3474 @opencatbox{Categories:}
3475 @category{Package draw}
3482 @anchor{xtics_secondary}
3483 @defvr {Graphic option} xtics_secondary
3484 Default value: @code{auto}
3486 This graphic option controls the way tic marks are drawn on the second @var{x} axis.
3488 See @mref{xtics_draw} for a complete description.
3490 @opencatbox{Categories:}
3491 @category{Package draw}
3498 @anchor{xtics_secondary_axis}
3499 @defvr {Graphic option} xtics_secondary_axis
3500 Default value: @code{false}
3502 If @code{xtics_secondary_axis} is @code{true}, tic marks and their labels are plotted just
3503 along the secondary @var{x} axis, if it is @code{false} tics are plotted on the border.
3505 Since this is a global graphics option, its position in the scene description
3508 @opencatbox{Categories:}
3509 @category{Package draw}
3517 @defvr {Graphic option} xu_grid
3520 @code{xu_grid} is the number of coordinates of the first variable
3521 (@code{x} in explicit and @code{u} in parametric 3d surfaces) to
3522 build the grid of sample points.
3524 This option affects the following graphic objects:
3527 @code{gr3d}: @code{explicit} and @code{parametric_surface}.
3533 (%i1) draw3d(xu_grid = 10,
3535 explicit(x^2+y^2,x,-3,3,y,-3,3) )$
3538 See also @mrefdot{yv_grid}
3540 @opencatbox{Categories:}
3541 @category{Package draw}
3550 @defvr {Graphic option} xy_file
3551 Default value: @code{""} (empty string)
3553 @code{xy_file} is the name of the file where the coordinates will be saved
3554 after clicking with the mouse button and hitting the 'x' key. By default,
3555 no coordinates are saved.
3557 Since this is a global graphics option, its position in the scene description
3560 @opencatbox{Categories:}
3561 @category{Package draw}
3570 @defvr {Graphic option} xyplane
3571 Default value: @code{false}
3573 Allocates the xy-plane in 3D scenes. When @code{xyplane} is
3574 @code{false}, the xy-plane is placed automatically; when it is
3575 a real number, the xy-plane intersects the z-axis at this level.
3576 This option has no effect in 2D scenes.
3578 Since this is a global graphics option, its position in the scene description
3584 (%i1) draw3d(xyplane = %e-2,
3585 explicit(x^2+y^2,x,-1,1,y,-1,1))$
3588 @opencatbox{Categories:}
3589 @category{Package draw}
3598 @defvr {Graphic option} y_voxel
3601 @code{y_voxel} is the number of voxels in the y direction to
3602 be used by the @i{marching cubes algorithm} implemented
3603 by the 3d @code{implicit} object. It is also used by graphic
3604 object @mrefdot{region}
3606 @opencatbox{Categories:}
3607 @category{Package draw}
3615 @defvr {Graphic option} yaxis
3616 Default value: @code{false}
3618 If @code{yaxis} is @code{true}, the @var{y} axis is drawn.
3620 Since this is a global graphics option, its position in the scene description
3626 (%i1) draw2d(explicit(x^3,x,-1,1),
3628 yaxis_color = blue)$
3631 See also @mrefcomma{yaxis_width} @mref{yaxis_type} and @mrefdot{yaxis_color}
3633 @opencatbox{Categories:}
3634 @category{Package draw}
3641 @anchor{yaxis_color}
3642 @defvr {Graphic option} yaxis_color
3643 Default value: @code{"black"}
3645 @code{yaxis_color} specifies the color for the @var{y} axis. See
3646 @code{color} to know how colors are defined.
3648 Since this is a global graphics option, its position in the scene description
3654 (%i1) draw2d(explicit(x^3,x,-1,1),
3659 See also @mrefcomma{yaxis} @mref{yaxis_width} and @mrefdot{yaxis_type}
3661 @opencatbox{Categories:}
3662 @category{Package draw}
3669 @anchor{yaxis_secondary}
3670 @defvr {Graphic option} yaxis_secondary
3671 Default value: @code{false}
3673 If @code{yaxis_secondary} is @code{true}, function values can be plotted with
3674 respect to the second @var{y} axis, which will be drawn on the right side of the
3677 Note that this is a local graphics option which only affects to 2d plots.
3683 explicit(sin(x),x,0,10),
3684 yaxis_secondary = true,
3685 ytics_secondary = true,
3687 explicit(100*sin(x+0.1)+2,x,0,10));
3690 See also @mrefcomma{yrange_secondary} @mrefcomma{ytics_secondary} @mref{ytics_rotate_secondary}
3691 and @code{ytics_axis_secondary}
3692 @c TODO: Document ytics_axis_secondary
3694 @opencatbox{Categories:}
3695 @category{Package draw}
3703 @defvr {Graphic option} yaxis_type
3704 Default value: @code{dots}
3706 @code{yaxis_type} indicates how the @var{y} axis is displayed;
3707 possible values are @code{solid} and @code{dots}.
3709 Since this is a global graphics option, its position in the scene description
3715 (%i1) draw2d(explicit(x^3,x,-1,1),
3717 yaxis_type = solid)$
3720 See also @mrefcomma{yaxis} @mref{yaxis_width} and @mrefdot{yaxis_color}
3722 @opencatbox{Categories:}
3723 @category{Package draw}
3730 @anchor{yaxis_width}
3731 @defvr {Graphic option} yaxis_width
3734 @code{yaxis_width} is the width of the @var{y} axis.
3735 Its value must be a positive number.
3737 Since this is a global graphics option, its position in the scene description
3743 (%i1) draw2d(explicit(x^3,x,-1,1),
3748 See also @mrefcomma{yaxis} @mref{yaxis_type} and @mrefdot{yaxis_color}
3750 @opencatbox{Categories:}
3751 @category{Package draw}
3758 @anchor{ylabel_draw}
3759 @defvr {Graphic option} ylabel
3760 Default value: @code{""}
3762 Option @code{ylabel}, a string, is the label for the @var{y} axis.
3763 By default, the axis is labeled with string @code{"y"}.
3765 Since this is a global graphics option, its position in the scene description
3771 (%i1) draw2d(xlabel = "Time",
3772 ylabel = "Population",
3773 explicit(exp(u),u,-2,2) )$
3776 See also @mrefcomma{xlabel_draw} @mrefcomma{xlabel_secondary} @mrefcomma{ylabel_secondary} and @mrefdot{zlabel_draw}
3778 @opencatbox{Categories:}
3779 @category{Package draw}
3786 @anchor{ylabel_secondary}
3787 @defvr {Graphic option} ylabel_secondary
3788 Default value: @code{""} (empty string)
3790 Option @code{ylabel_secondary}, a string, is the label for the secondary @var{y} axis.
3791 By default, no label is written.
3793 Since this is a global graphics option, its position in the scene description
3800 key_pos=bottom_right,
3803 ylabel="I[A]",ylabel_secondary="P[W]",
3804 explicit(sin(t),t,0,10),
3805 yaxis_secondary=true,
3806 ytics_secondary=true,
3807 color=red,key="Power",
3808 explicit((sin(t))^2,t,0,10)
3812 See also @mrefcomma{xlabel_draw} @mrefcomma{xlabel_secondary} @mref{ylabel_draw} and @mrefdot{zlabel_draw}
3814 @opencatbox{Categories:}
3815 @category{Package draw}
3823 @defvr {Graphic option} yrange
3824 Default value: @code{auto}
3826 If @code{yrange} is @code{auto}, the range for the @var{y} coordinate is
3827 computed automatically.
3829 If the user wants a specific interval for @var{y}, it must be given as a
3830 Maxima list, as in @code{yrange=[-2, 3]}.
3832 Since this is a global graphics option, its position in the scene description
3838 (%i1) draw2d(yrange = [-2,3],
3839 explicit(x^2,x,-1,1),
3843 See also @mrefcomma{xrange} @mref{yrange_secondary} and @mrefdot{zrange}
3845 @opencatbox{Categories:}
3846 @category{Package draw}
3853 @anchor{yrange_secondary}
3854 @defvr {Graphic option} yrange_secondary
3855 Default value: @code{auto}
3857 If @code{yrange_secondary} is @code{auto}, the range for the second @var{y} axis is
3858 computed automatically.
3860 If the user wants a specific interval for the second @var{y} axis, it must be given as a
3861 Maxima list, as in @code{yrange_secondary=[-2, 3]}.
3863 Since this is a global graphics option, its position in the scene description
3870 explicit(sin(x),x,0,10),
3871 yaxis_secondary = true,
3872 ytics_secondary = true,
3874 yrange_secondary = [-20, 20],
3876 explicit(100*sin(x+0.1)+2,x,0,10)) $
3879 See also @mrefcomma{xrange} @mref{yrange} and @mrefdot{zrange}
3881 @opencatbox{Categories:}
3882 @category{Package draw}
3889 @defvr {Graphic option} ytics
3890 Default value: @code{true}
3892 This graphic option controls the way tic marks are drawn on the @var{y} axis.
3894 See @code{xtics} for a complete description.
3896 @opencatbox{Categories:}
3897 @category{Package draw}
3905 @defvr {Graphic option} ytics_axis
3906 Default value: @code{false}
3908 If @code{ytics_axis} is @code{true}, tic marks and their labels are plotted just
3909 along the @var{y} axis, if it is @code{false} tics are plotted on the border.
3911 Since this is a global graphics option, its position in the scene description
3914 @opencatbox{Categories:}
3915 @category{Package draw}
3923 @anchor{ytics_rotate}
3924 @defvr {Graphic option} ytics_rotate
3925 Default value: @code{false}
3927 If @code{ytics_rotate} is @code{true}, tic marks on the @var{y} axis are rotated
3930 Since this is a global graphics option, its position in the scene description
3933 @opencatbox{Categories:}
3934 @category{Package draw}
3941 @anchor{ytics_rotate_secondary}
3942 @defvr {Graphic option} ytics_rotate_secondary
3943 Default value: @code{false}
3945 If @code{ytics_rotate_secondary} is @code{true}, tic marks on the secondary @var{y} axis are rotated
3948 Since this is a global graphics option, its position in the scene description
3951 @opencatbox{Categories:}
3952 @category{Package draw}
3959 @anchor{ytics_secondary}
3960 @defvr {Graphic option} ytics_secondary
3961 Default value: @code{auto}
3963 This graphic option controls the way tic marks are drawn on the second @var{y} axis.
3965 See @code{xtics} for a complete description.
3967 @opencatbox{Categories:}
3968 @category{Package draw}
3975 @anchor{ytics_secondary_axis}
3976 @defvr {Graphic option} ytics_secondary_axis
3977 Default value: @code{false}
3979 If @code{ytics_secondary_axis} is @code{true}, tic marks and their labels are plotted just
3980 along the secondary @var{y} axis, if it is @code{false} tics are plotted on the border.
3982 Since this is a global graphics option, its position in the scene description
3985 @opencatbox{Categories:}
3986 @category{Package draw}
3994 @defvr {Graphic option} yv_grid
3997 @code{yv_grid} is the number of coordinates of the second variable
3998 (@code{y} in explicit and @code{v} in parametric 3d surfaces) to
3999 build the grid of sample points.
4001 This option affects the following graphic objects:
4004 @code{gr3d}: @mref{explicit} and @mref{parametric_surface}.
4010 (%i1) draw3d(xu_grid = 10,
4012 explicit(x^2+y^2,x,-3,3,y,-3,3) )$
4014 @figure{draw_xugrid}
4016 See also @mrefdot{xu_grid}
4018 @opencatbox{Categories:}
4019 @category{Package draw}
4026 @defvr {Graphic option} z_voxel
4029 @code{z_voxel} is the number of voxels in the z direction to
4030 be used by the @i{marching cubes algorithm} implemented
4031 by the 3d @code{implicit} object.
4033 @opencatbox{Categories:}
4034 @category{Package draw}
4041 @defvr {Graphic option} zaxis
4042 Default value: @code{false}
4044 If @code{zaxis} is @code{true}, the @var{z} axis is drawn in 3D plots.
4045 This option has no effect in 2D scenes.
4047 Since this is a global graphics option, its position in the scene description
4053 (%i1) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1),
4056 zaxis_color = blue)$
4059 See also @mrefcomma{zaxis_width} @mref{zaxis_type} and @mrefdot{zaxis_color}
4061 @opencatbox{Categories:}
4062 @category{Package draw}
4069 @anchor{zaxis_color}
4070 @defvr {Graphic option} zaxis_color
4071 Default value: @code{"black"}
4073 @code{zaxis_color} specifies the color for the @var{z} axis. See
4074 @code{color} to know how colors are defined.
4075 This option has no effect in 2D scenes.
4077 Since this is a global graphics option, its position in the scene description
4083 (%i1) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1),
4089 See also @mrefcomma{zaxis} @mref{zaxis_width} and @mrefdot{zaxis_type}
4091 @opencatbox{Categories:}
4092 @category{Package draw}
4100 @defvr {Graphic option} zaxis_type
4101 Default value: @code{dots}
4103 @code{zaxis_type} indicates how the @var{z} axis is displayed;
4104 possible values are @code{solid} and @code{dots}.
4105 This option has no effect in 2D scenes.
4107 Since this is a global graphics option, its position in the scene description
4113 (%i1) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1),
4115 zaxis_type = solid)$
4118 See also @mrefcomma{zaxis} @mref{zaxis_width} and @mrefdot{zaxis_color}
4120 @opencatbox{Categories:}
4121 @category{Package draw}
4129 @anchor{zaxis_width}
4130 @defvr {Graphic option} zaxis_width
4133 @code{zaxis_width} is the width of the @var{z} axis.
4134 Its value must be a positive number. This option has no effect in 2D scenes.
4136 Since this is a global graphics option, its position in the scene description
4142 (%i1) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1),
4148 See also @mrefcomma{zaxis} @mref{zaxis_type} and @mrefdot{zaxis_color}
4150 @opencatbox{Categories:}
4151 @category{Package draw}
4158 @anchor{zlabel_draw}
4159 @defvr {Graphic option} zlabel
4160 Default value: @code{""}
4162 Option @code{zlabel}, a string, is the label for the @var{z} axis.
4163 By default, the axis is labeled with string @code{"z"}.
4165 Since this is a global graphics option, its position in the scene description
4171 (%i1) draw3d(zlabel = "Z variable",
4172 ylabel = "Y variable",
4173 explicit(sin(x^2+y^2),x,-2,2,y,-2,2),
4174 xlabel = "X variable" )$
4177 See also @mrefcomma{xlabel_draw} @mrefcomma{ylabel_draw} and @mrefdot{zlabel_rotate}
4179 @opencatbox{Categories:}
4180 @category{Package draw}
4188 @anchor{zlabel_rotate}
4189 @defvr {Graphic option} zlabel_rotate
4190 Default value: @code{"auto"}
4192 This graphics option allows to choose if the z axis label of 3d plots is
4193 drawn horizontal (@code{false}), vertical (@code{true}) or if maxima
4194 automatically chooses an orientation based on the length of the label
4197 Since this is a global graphics option, its position in the scene description
4204 explicit(sin(x)*sin(y),x,0,10,y,0,10),
4209 See also @mrefdot{zlabel_draw}
4211 @opencatbox{Categories:}
4212 @category{Package draw}
4221 @defvr {Graphic option} zrange
4222 Default value: @code{auto}
4224 If @code{zrange} is @code{auto}, the range for the @var{z} coordinate is
4225 computed automatically.
4227 If the user wants a specific interval for @var{z}, it must be given as a
4228 Maxima list, as in @code{zrange=[-2, 3]}.
4230 Since this is a global graphics option, its position in the scene description
4236 (%i1) draw3d(yrange = [-3,3],
4238 explicit(x^2+y^2,x,-1,1,y,-1,1),
4242 See also @mref{xrange} and @mrefdot{yrange}
4244 @opencatbox{Categories:}
4245 @category{Package draw}
4251 @defvr {Graphic option} ztics
4252 Default value: @code{true}
4254 This graphic option controls the way tic marks are drawn on the @var{z} axis.
4256 See @mref{xtics_draw} for a complete description.
4258 @opencatbox{Categories:}
4259 @category{Package draw}
4268 @defvr {Graphic option} ztics_axis
4269 Default value: @code{false}
4271 If @code{ztics_axis} is @code{true}, tic marks and their labels are plotted just
4272 along the @var{z} axis, if it is @code{false} tics are plotted on the border.
4274 Since this is a global graphics option, its position in the scene description
4277 @opencatbox{Categories:}
4278 @category{Package draw}
4284 @anchor{ztics_rotate}
4285 @defvr {Graphic option} ztics_rotate
4286 Default value: @code{false}
4288 If @code{ztics_rotate} is @code{true}, tic marks on the @var{z} axis are rotated
4291 Since this is a global graphics option, its position in the scene description
4294 @opencatbox{Categories:}
4295 @category{Package draw}
4303 @subsection Graphics objects
4308 @deffn {Graphic object} bars ([@var{x1},@var{h1},@var{w1}], [@var{x2},@var{h2},@var{w2}, ...])
4309 Draws vertical bars in 2D.
4313 @code{bars ([@var{x1},@var{h1},@var{w1}], [@var{x2},@var{h2},@var{w2}, ...])}
4314 draws bars centered at values @var{x1}, @var{x2}, ... with heights @var{h1}, @var{h2}, ...
4315 and widths @var{w1}, @var{w2}, ...
4317 This object is affected by the following @i{graphic options}: @mrefcomma{key}
4318 @mrefcomma{fill_color} @mref{fill_density} and @mrefdot{line_width}
4327 bars([0.8,5,0.4],[1.8,7,0.4],[2.8,-4,0.4]),
4332 bars([1.2,4,0.4],[2.2,-2,0.4],[3.2,5,0.4]),
4337 @opencatbox{Categories:}
4338 @category{Package draw}
4345 @anchor{cylindrical}
4346 @deffn {Graphic object} cylindrical (@var{radius}, @var{z}, @var{minz}, @var{maxz}, @var{azi}, @var{minazi}, @var{maxazi})
4347 Draws 3D functions defined in cylindrical coordinates.
4351 @code{cylindrical(@var{radius}, @var{z}, @var{minz}, @var{maxz}, @var{azi},
4352 @var{minazi}, @var{maxazi})} plots the function @code{@var{radius}(@var{z},
4353 @var{azi})} defined in cylindrical coordinates, with variable @var{z} taking
4354 values from @var{minz} to @var{maxz} and @i{azimuth} @var{azi} taking values
4355 from @var{minazi} to @var{maxazi}.
4357 This object is affected by the following @i{graphic options}: @mrefcomma{xu_grid}
4358 @mrefcomma{yv_grid} @mrefcomma{line_type} @mrefcomma{key} @mrefcomma{wired_surface} @code{enhanced3d} and @code{color}
4363 (%i1) draw3d(cylindrical(1,z,-2,2,az,0,2*%pi))$
4365 @figure{draw_cylindrical}
4367 @opencatbox{Categories:}
4368 @category{Package draw}
4376 @anchor{elevation_grid}
4377 @deffn {Graphic object} elevation_grid (@var{mat},@var{x0},@var{y0},@var{width},@var{height})
4378 Draws matrix @var{mat} in 3D space. @var{z} values are taken from @var{mat},
4379 the abscissas range from @var{x0} to @math{@var{x0} + @var{width}}
4380 and ordinates from @var{y0} to @math{@var{y0} + @var{height}}. Element @math{a(1,1)}
4381 is projected on point @math{(x0,y0+height)}, @math{a(1,n)} on @math{(x0+width,y0+height)},
4382 @math{a(m,1)} on @math{(x0,y0)}, and @math{a(m,n)} on @math{(x0+width,y0)}.
4384 This object is affected by the following @i{graphic options}: @mrefcomma{line_type},
4385 @mref{line_width} @mrefcomma{key} @mrefcomma{wired_surface} @mref{enhanced3d} and @code{color}
4387 In older versions of Maxima, @mref{elevation_grid} was called @mrefdot{mesh}
4388 See also @mrefdot{mesh}
4395 makelist(makelist(random(10.0),k,1,30),i,1,20)) $
4398 elevation_grid(m,0,0,3,2),
4401 surface_hide = true);
4403 @figure{draw_elevation_grid}
4405 @opencatbox{Categories:}
4406 @category{Package draw}
4415 @deffn {Graphic object} ellipse (@var{xc}, @var{yc}, @var{a}, @var{b}, @var{ang1}, @var{ang2})
4416 Draws ellipses and circles in 2D.
4421 @code{ellipse (@var{xc}, @var{yc}, @var{a}, @var{b}, @var{ang1}, @var{ang2})}
4422 plots an ellipse centered at @code{[@var{xc}, @var{yc}]} with horizontal and vertical
4423 semi axis @var{a} and @var{b}, respectively, starting at angle @var{ang1} with an amplitude
4424 equal to angle @var{ang2}.
4426 This object is affected by the following @i{graphic options}: @mrefcomma{nticks}
4427 @mrefcomma{transparent} @mrefcomma{fill_color} @mrefcomma{border} @code{line_width},
4428 @mrefcomma{line_type} @mref{key} and @code{color}
4433 (%i1) draw2d(transparent = false,
4436 transparent = false,
4438 ellipse(0,6,3,2,270,-270),
4439 /* center (x,y), a, b, start & end in degrees */
4443 ellipse(2.5,6,2,3,30,-90),
4447 @figure{draw_ellipse}
4449 @opencatbox{Categories:}
4450 @category{Package draw}
4457 @deffn {Graphic object} errors ([@var{x1}, @var{x2}, @dots{}], [@var{y1}, @var{y2}, @dots{}])
4458 Draws points with error bars, horizontally, vertically or both, depending on the
4459 value of option @code{error_type}.
4463 If @code{error_type = x}, arguments to @code{errors} must be of the form
4464 @code{[x, y, xdelta]} or @code{[x, y, xlow, xhigh]}. If @code{error_type = y},
4465 arguments must be of the form @code{[x, y, ydelta]} or
4466 @code{[x, y, ylow, yhigh]}. If @code{error_type = xy} or
4467 @code{error_type = boxes}, arguments to @code{errors} must be of the form
4468 @code{[x, y, xdelta, ydelta]} or @code{[x, y, xlow, xhigh, ylow, yhigh]}.
4470 See also @mrefdot{error_type}
4472 This object is affected by the following @i{graphic options}: @mrefcomma{error_type}
4473 @mrefcomma{points_joined} @mrefcomma{line_width} @mrefcomma{key} @mrefcomma{line_type}
4474 @code{color} @mrefcomma{fill_density} @mref{xaxis_secondary} and @mrefdot{yaxis_secondary}
4476 Option @mref{fill_density} is only relevant when @code{error_type=boxes}.
4480 Horizontal error bars.
4485 errors([[1,2,1], [3,5,3], [10,3,1], [17,6,2]]))$
4487 @figure{draw_errors}
4489 Vertical and horizontal error bars.
4494 points_joined = true,
4496 errors([[1,2,1,2], [3,5,2,1], [10,3,1,1], [17,6,1/2,2]]));
4498 @figure{draw_errors2}
4500 @opencatbox{Categories:}
4501 @category{Package draw}
4508 @deffn {Graphic object} explicit @
4509 @fname{explicit} (@var{expr},@var{var},@var{minval},@var{maxval}) @
4510 @fname{explicit} (@var{fcn},@var{var},@var{minval},@var{maxval}) @
4511 @fname{explicit} (@var{expr},@var{var1},@var{minval1},@var{maxval1},@var{var2},@var{minval2},@var{maxval2}) @
4512 @fname{explicit} (@var{fcn},@var{var1},@var{minval1},@var{maxval1},@var{var2},@var{minval2},@var{maxval2})
4514 Draws explicit functions in 2D and 3D.
4518 @code{explicit(@var{fcn},@var{var},@var{minval},@var{maxval})} plots explicit function @var{fcn},
4519 with variable @var{var} taking values from @var{minval} to @var{maxval}.
4521 This object is affected by the following @i{graphic options}: @mrefcomma{nticks}
4522 @code{adapt_depth}, @mrefcomma{draw_realpart} @mrefcomma{line_width} @mrefcomma{line_type} @mrefcomma{key}
4523 @mrefcomma{filled_func} @mref{fill_color} and @code{color}
4528 (%i1) draw2d(line_width = 3,
4530 explicit(x^2,x,-3,3) )$
4532 @figure{draw_explicit}
4534 (%i2) draw2d(fill_color = brown,
4536 explicit(x^2,x,-3,3) )$
4538 @figure{draw_explicit2}
4542 @code{explicit(@var{fcn}, @var{var1}, @var{minval1}, @var{maxval1}, @var{var2},
4543 @var{minval2}, @var{maxval2})} plots the explicit function @var{fcn}, with
4544 variable @var{var1} taking values from @var{minval1} to @var{maxval1} and
4545 variable @var{var2} taking values from @var{minval2} to @var{maxval2}.
4547 This object is affected by the following @i{graphic options}: @mrefcomma{draw_realpart} @mrefcomma{xu_grid}
4548 @mrefcomma{yv_grid} @mrefcomma{line_type} @mrefcomma{line_width} @mrefcomma{key} @mrefcomma{wired_surface}
4549 @mref{enhanced3d} and @code{color}.
4554 (%i1) draw3d(key = "Gauss",
4556 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3),
4560 explicit(x+y,x,-5,5,y,-5,5),
4561 surface_hide = true)$
4563 @figure{draw_explicit3}
4565 See also @mref{filled_func} for filled functions.
4567 @opencatbox{Categories:}
4568 @category{Package draw}
4576 @deffn {Graphic object} image (@var{im},@var{x0},@var{y0},@var{width},@var{height})
4577 Renders images in 2D.
4581 @code{image (@var{im},@var{x0},@var{y0},@var{width},@var{height})} plots image @var{im} in the rectangular
4582 region from vertex @code{(@var{x0},@var{y0})} to @code{(x0+@var{width},y0+@var{height})} on the real
4583 plane. Argument @var{im} must be a matrix of real numbers, a matrix of
4584 vectors of length three or a @var{picture} object.
4586 If @var{im} is a matrix of real numbers or a @var{levels picture} object,
4587 pixel values are interpreted according to graphic option @code{palette},
4588 which is a vector of length three with components
4589 ranging from -36 to +36; each value is an index for a formula mapping the levels
4590 onto red, green and blue colors, respectively:
4594 6: x^4 7: sqrt(x) 8: sqrt(sqrt(x))
4595 9: sin(90x) 10: cos(90x) 11: |x-0.5|
4596 12: (2x-1)^2 13: sin(180x) 14: |cos(180x)|
4597 15: sin(360x) 16: cos(360x) 17: |sin(360x)|
4598 18: |cos(360x)| 19: |sin(720x)| 20: |cos(720x)|
4599 21: 3x 22: 3x-1 23: 3x-2
4600 24: |3x-1| 25: |3x-2| 26: (3x-1)/2
4601 27: (3x-2)/2 28: |(3x-1)/2| 29: |(3x-2)/2|
4602 30: x/0.32-0.78125 31: 2*x-0.84
4603 32: 4x;1;-2x+1.84;x/0.08-11.5
4604 33: |2*x - 0.5| 34: 2*x 35: 2*x - 0.5
4607 negative numbers mean negative colour component.
4609 @code{palette = gray} and @code{palette = color} are short cuts for
4610 @code{palette = [3,3,3]} and @code{palette = [7,5,15]}, respectively.
4612 If @var{im} is a matrix of vectors of length three or an @var{rgb picture} object,
4613 they are interpreted as red, green and blue color components.
4617 If @var{im} is a matrix of real numbers, pixel values are interpreted according
4618 to graphic option @code{palette}.
4622 makelist(makelist(random(200),i,1,30),i,1,30))$
4623 (%i2) /* palette = color, default */
4624 draw2d(image(im,0,0,30,30))$
4628 (%i3) draw2d(palette = gray, image(im,0,0,30,30))$
4630 @figure{draw_image2}
4632 (%i4) draw2d(palette = [15,20,-4],
4634 image(im,0,0,30,30))$
4636 @figure{draw_image3}
4638 See also @mrefdot{colorbox}
4640 If @var{im} is a matrix of vectors of length three, they are interpreted
4641 as red, green and blue color components.
4646 makelist([random(300),
4648 random(300)],i,1,30),i,1,30))$
4649 (%i2) draw2d(image(im,0,0,30,30))$
4651 @figure{draw_image4}
4653 Package @code{draw} automatically loads package @code{picture}. In this
4654 example, a level picture object is built by hand and then rendered.
4656 (%i1) im: make_level_picture([45,87,2,134,204,16],3,2);
4657 (%o1) picture(level, 3, 2, @{Array: #(45 87 2 134 204 16)@})
4658 (%i2) /* default color palette */
4659 draw2d(image(im,0,0,30,30))$
4661 @figure{draw_image5}
4663 (%i3) /* gray palette */
4664 draw2d(palette = gray,
4665 image(im,0,0,30,30))$
4667 @figure{draw_image6}
4669 An xpm file is read and then rendered.
4671 (%i1) im: read_xpm("myfile.xpm")$
4672 (%i2) draw2d(image(im,0,0,10,7))$
4675 See also @mrefcomma{make_level_picture} @mref{make_rgb_picture} and @mrefdot{read_xpm}
4677 @url{http://www.telefonica.net/web2/biomates/maxima/gpdraw/image}@*
4678 contains more elaborated examples.
4680 @opencatbox{Categories:}
4681 @category{Package draw}
4690 @deffn {Graphic object} implicit @
4691 @fname{implicit} (@var{fcn},@var{x},@var{xmin},@var{xmax},@var{y},@var{ymin},@var{ymax}) @
4692 @fname{implicit} (@var{fcn},@var{x},@var{xmin},@var{xmax},@var{y},@var{ymin},@var{ymax},@var{z},@var{zmin},@var{zmax})
4694 Draws implicit functions in 2D and 3D.
4698 @code{implicit(@var{fcn},@var{x},@var{xmin},@var{xmax},@var{y},@var{ymin},@var{ymax})}
4699 plots the implicit function defined by @var{fcn}, with variable @var{x} taking values
4700 from @var{xmin} to @var{xmax}, and variable @var{y} taking values
4701 from @var{ymin} to @var{ymax}.
4703 This object is affected by the following @i{graphic options}: @mrefcomma{ip_grid}
4704 @mrefcomma{ip_grid_in} @mrefcomma{line_width} @mrefcomma{line_type} @mref{key} and @code{color}.
4709 (%i1) draw2d(grid = true,
4711 key = "y^2=x^3-2*x+1",
4712 implicit(y^2=x^3-2*x+1, x, -4,4, y, -4,4),
4714 key = "x^3+y^3 = 3*x*y^2-x-1",
4715 implicit(x^3+y^3 = 3*x*y^2-x-1, x,-4,4, y,-4,4),
4716 title = "Two implicit functions" )$
4718 @figure{draw_implicit}
4722 @code{implicit (@var{fcn},@var{x},@var{xmin},@var{xmax}, @var{y},@var{ymin},@var{ymax}, @var{z},@var{zmin},@var{zmax})}
4723 plots the implicit surface defined by @var{fcn}, with variable @var{x} taking values
4724 from @var{xmin} to @var{xmax}, variable @var{y} taking values
4725 from @var{ymin} to @var{ymax} and variable @var{z} taking values
4726 from @var{zmin} to @var{zmax}. This object implements the @i{marching cubes algorithm}.
4728 This object is affected by the following @i{graphic options}: @mrefcomma{x_voxel}
4729 @mrefcomma{y_voxel} @mrefcomma{z_voxel} @mrefcomma{line_width} @mrefcomma{line_type} @mrefcomma{key}
4730 @mrefcomma{wired_surface} @mref{enhanced3d} and @code{color}.
4737 implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015,
4738 x,-1,1,y,-1.2,2.3,z,-1,1),
4741 @figure{draw_implicit2}
4743 @opencatbox{Categories:}
4744 @category{Package draw}
4751 @deffn {Graphic object} label @
4752 @fname{label} ([@var{string},@var{x},@var{y}],...) @
4753 @fname{label} ([@var{string},@var{x},@var{y},@var{z}],...)
4755 Writes labels in 2D and 3D.
4757 Colored labels work only with Gnuplot 4.3 and up.
4759 This object is affected by the following @i{graphic options}: @mrefcomma{label_alignment}
4760 @mref{label_orientation} and @code{color}.
4764 @code{label([@var{string},@var{x},@var{y}])} writes the @var{string} at point
4765 @code{[@var{x},@var{y}]}.
4770 (%i1) draw2d(yrange = [0.1,1.4],
4772 label(["Label in red",0,0.3]),
4774 label(["Label in blue",0,0.6]),
4776 label(["Label in light-blue",0,0.9],
4777 ["Another light-blue",0,1.2]) )$
4783 @code{label([@var{string},@var{x},@var{y},@var{z}])} writes the @var{string} at point
4784 @code{[@var{x},@var{y},@var{z}]}.
4789 (%i1) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3),
4791 label(["UP 1",-2,0,3], ["UP 2",1.5,0,4]),
4793 label(["DOWN 1",2,0,-3]) )$
4795 @figure{draw_label2}
4797 @opencatbox{Categories:}
4798 @category{Package draw}
4805 @deffn {Graphic object} mesh (@var{row_1},@var{row_2},...)
4806 Draws a quadrangular mesh in 3D.
4810 Argument @var{row_i} is a list of @var{n} 3D points of the form
4811 @code{[[x_i1,y_i1,z_i1], ...,[x_in,y_in,z_in]]}, and all rows are
4812 of equal length. All these points define an arbitrary surface in 3D and
4813 in some sense it's a generalization of the @code{elevation_grid} object.
4815 This object is affected by the following @i{graphic options}: @mrefcomma{line_type}
4816 @mrefcomma{line_width} @mrefcomma{color} @mrefcomma{key} @mrefcomma{wired_surface} @mref{enhanced3d} and @mrefdot{transform}
4824 mesh([[1,1,3], [7,3,1],[12,-2,4],[15,0,5]],
4825 [[2,7,8], [4,3,1],[10,5,8], [12,7,1]],
4826 [[-2,11,10],[6,9,5],[6,15,1], [20,15,2]])) $
4830 Plotting a triangle in 3D.
4835 mesh([[1,0,0],[0,1,0]],
4836 [[0,0,1],[0,0,1]])) $
4844 surface_hide = true,
4847 mesh([[0,0,0], [0,1,0]],
4848 [[2,0,2], [2,2,2]]),
4850 mesh([[0,0,2], [0,1,2]],
4851 [[2,0,4], [2,2,4]])) $
4855 @opencatbox{Categories:}
4856 @category{Package draw}
4863 @deffn {Graphic object} parametric @
4864 @fname{parametric} (@var{xfun},@var{yfun},@var{par},@var{parmin},@var{parmax}) @
4865 @fname{parametric} (@var{xfun},@var{yfun},@var{zfun},@var{par},@var{parmin},@var{parmax})
4867 Draws parametric functions in 2D and 3D.
4869 This object is affected by the following @i{graphic options}: @mrefcomma{nticks}
4870 @mrefcomma{line_width} @mrefcomma{line_type} @mrefcomma{key} @mref{color} and @mrefdot{enhanced3d}
4874 The command @code{parametric(@var{xfun}, @var{yfun}, @var{par}, @var{parmin},
4875 @var{parmax})} plots the parametric function @code{[@var{xfun}, @var{yfun}]},
4876 with parameter @var{par} taking values from @var{parmin} to @var{parmax}.
4881 (%i1) draw2d(explicit(exp(x),x,-1,3),
4883 key = "This is the parametric one!!",
4884 parametric(2*cos(rrr),rrr^2,rrr,0,2*%pi))$
4886 @figure{draw_parametric}
4890 @code{parametric(@var{xfun}, @var{yfun}, @var{zfun}, @var{par}, @var{parmin},
4891 @var{parmax})} plots the parametric curve @code{[@var{xfun}, @var{yfun},
4892 @var{zfun}]}, with parameter @var{par} taking values from @var{parmin} to
4898 (%i1) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3),
4900 parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2),
4903 parametric(t^2,sin(t),2+t,t,0,2),
4904 surface_hide = true,
4905 title = "Surface & curves" )$
4907 @figure{draw_parametric2}
4909 @opencatbox{Categories:}
4910 @category{Package draw}
4917 @anchor{parametric_surface}
4918 @deffn {Graphic object} parametric_surface (@var{xfun}, @var{yfun}, @var{zfun}, @var{par1}, @var{par1min}, @var{par1max}, @var{par2}, @var{par2min}, @var{par2max})
4919 Draws parametric surfaces in 3D.
4923 The command @code{parametric_surface(@var{xfun}, @var{yfun}, @var{zfun},
4924 @var{par1}, @var{par1min}, @var{par1max}, @var{par2}, @var{par2min},
4925 @var{par2max})} plots the parametric surface @code{[@var{xfun}, @var{yfun},
4926 @var{zfun}]}, with parameter @var{par1} taking values from @var{par1min} to
4927 @var{par1max} and parameter @var{par2} taking values from @var{par2min} to
4930 This object is affected by the following @i{graphic options}: @mrefcomma{draw_realpart} @mrefcomma{xu_grid}
4931 @mrefcomma{yv_grid} @mrefcomma{line_type} @mrefcomma{line_width} @mrefcomma{key} @mrefcomma{wired_surface} @mref{enhanced3d}
4937 (%i1) draw3d(title = "Sea shell",
4941 surface_hide = true,
4942 parametric_surface(0.5*u*cos(u)*(cos(v)+1),
4943 0.5*u*sin(u)*(cos(v)+1),
4944 u*sin(v) - ((u+3)/8*%pi)^2 - 20,
4945 u, 0, 13*%pi, v, -%pi, %pi) )$
4947 @figure{draw_parametric3}
4949 @opencatbox{Categories:}
4950 @category{Package draw}
4958 @deffn {Graphic object} points @
4959 @fname{points} ([[@var{x1},@var{y1}], [@var{x2},@var{y2}],...]) @
4960 @fname{points} ([@var{x1},@var{x2},...], [@var{y1},@var{y2},...]) @
4961 @fname{points} ([@var{y1},@var{y2},...]) @
4962 @fname{points} ([[@var{x1},@var{y1},@var{z1}], [@var{x2},@var{y2},@var{z2}],...]) @
4963 @fname{points} ([@var{x1},@var{x2},...], [@var{y1},@var{y2},...], [@var{z1},@var{z2},...]) @
4964 @fname{points} (@var{matrix}) @
4965 @fname{points} (@var{1d_y_array}) @
4966 @fname{points} (@var{1d_x_array}, @var{1d_y_array}) @
4967 @fname{points} (@var{1d_x_array}, @var{1d_y_array}, @var{1d_z_array}) @
4968 @fname{points} (@var{2d_xy_array}) @
4969 @fname{points} (@var{2d_xyz_array})
4971 Draws points in 2D and 3D.
4973 This object is affected by the following @i{graphic options}: @mrefcomma{point_size}
4974 @mrefcomma{point_type} @mrefcomma{points_joined} @mrefcomma{line_width} @mrefcomma{key}
4975 @mref{line_type} and @code{color}. In 3D mode, it is also affected by @mref{enhanced3d}
4979 @code{points ([[@var{x1},@var{y1}], [@var{x2},@var{y2}],...])} or
4980 @code{points ([@var{x1},@var{x2},...], [@var{y1},@var{y2},...])}
4981 plots points @code{[x1,y1]}, @code{[x2,y2]}, etc. If abscissas
4982 are not given, they are set to consecutive positive integers, so that
4983 @code{points ([@var{y1},@var{y2},...])} draws points @code{[1,@var{y1}]}, @code{[2,@var{y2}]}, etc.
4984 If @var{matrix} is a two-column or two-row matrix, @code{points (@var{matrix})}
4985 draws the associated points. If @var{matrix} is an one-column or one-row matrix,
4986 abscissas are assigned automatically.
4988 If @var{1d_y_array} is a 1D lisp array of numbers, @code{points (@var{1d_y_array})} plots them
4989 setting abscissas to consecutive positive integers. @code{points (@var{1d_x_array}, @var{1d_y_array})}
4990 plots points with their coordinates taken from the two arrays passed as arguments. If
4991 @var{2d_xy_array} is a 2D array with two columns, or with two rows, @code{points (@var{2d_xy_array})}
4992 plots the corresponding points on the plane.
4996 Two types of arguments for @code{points}, a list of pairs and two lists
4997 of separate coordinates.
5000 key = "Small points",
5001 points(makelist([random(20),random(50)],k,1,10)),
5002 point_type = circle,
5004 points_joined = true,
5005 key = "Great points",
5006 points(makelist(k,k,1,20),makelist(random(30),k,1,20)),
5007 point_type = filled_down_triangle,
5008 key = "Automatic abscissas",
5012 @figure{draw_points}
5017 points_joined = impulses,
5020 points(makelist([random(20),random(50)],k,1,10)))$
5022 @figure{draw_points2}
5024 Array with ordinates.
5026 (%i1) a: make_array (flonum, 100) $
5027 (%i2) for i:0 thru 99 do a[i]: random(1.0) $
5028 (%i3) draw2d(points(a)) $
5030 @figure{draw_points3}
5032 Two arrays with separate coordinates.
5034 (%i1) x: make_array (flonum, 100) $
5035 (%i2) y: make_array (fixnum, 100) $
5036 (%i3) for i:0 thru 99 do (
5038 y[i]: random(10) ) $
5039 (%i4) draw2d(points(x, y)) $
5041 @figure{draw_points4}
5043 A two-column 2D array.
5045 (%i1) xy: make_array(flonum, 100, 2) $
5046 (%i2) for i:0 thru 99 do (
5047 xy[i, 0]: float(i/100),
5048 xy[i, 1]: random(10) ) $
5049 (%i3) draw2d(points(xy)) $
5051 @figure{draw_points5}
5053 Drawing an array filled with function @code{read_array}.
5055 (%i1) a: make_array(flonum,100) $
5056 (%i2) read_array (file_search ("pidigits.data"), a) $
5057 (%i3) draw2d(points(a)) $
5062 @code{points([[@var{x1}, @var{y1}, @var{z1}], [@var{x2}, @var{y2}, @var{z2}],
5063 ...])} or @code{points([@var{x1}, @var{x2}, ...], [@var{y1}, @var{y2}, ...],
5064 [@var{z1}, @var{z2},...])} plots points @code{[@var{x1}, @var{y1}, @var{z1}]},
5065 @code{[@var{x2}, @var{y2}, @var{z2}]}, etc. If @var{matrix} is a three-column
5066 or three-row matrix, @code{points (@var{matrix})} draws the associated points.
5068 When arguments are lisp arrays, @code{points (@var{1d_x_array}, @var{1d_y_array}, @var{1d_z_array})}
5069 takes coordinates from the three 1D arrays. If @var{2d_xyz_array} is a 2D array with three columns,
5070 or with three rows, @code{points (@var{2d_xyz_array})} plots the corresponding points.
5074 One tridimensional sample,
5076 (%i1) load ("numericalio")$
5077 (%i2) s2 : read_matrix (file_search ("wind.data"))$
5078 (%i3) draw3d(title = "Daily average wind speeds",
5080 points(args(submatrix (s2, 4, 5))) )$
5083 Two tridimensional samples,
5085 (%i1) load ("numericalio")$
5086 (%i2) s2 : read_matrix (file_search ("wind.data"))$
5088 title = "Daily average wind speeds. Two data sets",
5090 key = "Sample from stations 1, 2 and 3",
5091 points(args(submatrix (s2, 4, 5))),
5093 key = "Sample from stations 1, 4 and 5",
5094 points(args(submatrix (s2, 2, 3))) )$
5097 Unidimensional arrays,
5099 (%i1) x: make_array (fixnum, 10) $
5100 (%i2) y: make_array (fixnum, 10) $
5101 (%i3) z: make_array (fixnum, 10) $
5102 (%i4) for i:0 thru 9 do (
5105 z[i]: random(10) ) $
5106 (%i5) draw3d(points(x,y,z)) $
5108 @figure{draw_points6}
5110 Bidimensional colored array,
5112 (%i1) xyz: make_array(fixnum, 10, 3) $
5113 (%i2) for i:0 thru 9 do (
5114 xyz[i, 0]: random(10),
5115 xyz[i, 1]: random(10),
5116 xyz[i, 2]: random(10) ) $
5119 points_joined = true,
5122 @figure{draw_points7}
5124 Color numbers explicitly specified by the user.
5126 (%i1) pts: makelist([t,t^2,cos(t)], t, 0, 15)$
5127 (%i2) col_num: makelist(k, k, 1, length(pts))$
5129 enhanced3d = ['part(col_num,k),k],
5131 point_type = filled_circle,
5134 @figure{draw_points8}
5136 @opencatbox{Categories:}
5137 @category{Package draw}
5145 @deffn {Graphic object} polar (@var{radius},@var{ang},@var{minang},@var{maxang})
5146 Draws 2D functions defined in polar coordinates.
5150 @code{polar (@var{radius},@var{ang},@var{minang},@var{maxang})} plots function
5151 @code{@var{radius}(@var{ang})} defined in polar coordinates, with variable
5152 @var{ang} taking values from
5153 @var{minang} to @var{maxang}.
5155 This object is affected by the following @i{graphic options}: @mrefcomma{nticks}
5156 @mrefcomma{line_width} @mrefcomma{line_type} @mref{key} and @code{color}.
5161 (%i1) draw2d(user_preamble = "set grid polar",
5167 title = "Hyperbolic Spiral",
5168 polar(10/theta,theta,1,10*%pi) )$
5172 @opencatbox{Categories:}
5173 @category{Package draw}
5182 @deffn {Graphic object} polygon @
5183 @fname{polygon} ([[@var{x1}, @var{y1}], [@var{x2}, @var{y2}], @dots{}]) @
5184 @fname{polygon} ([@var{x1}, @var{x2}, @dots{}], [@var{y1}, @var{y2}, @dots{}])
5186 Draws polygons in 2D.
5190 The commands @code{polygon([[@var{x1}, @var{y1}], [@var{x2}, @var{y2}], ...])}
5191 or @code{polygon([@var{x1}, @var{x2}, ...], [@var{y1}, @var{y2}, ...])} plot on
5192 the plane a polygon with vertices @code{[@var{x1}, @var{y1}]}, @code{[@var{x2},
5195 This object is affected by the following @i{graphic options}: @mrefcomma{transparent}
5196 @mrefcomma{fill_color} @mrefcomma{border} @mrefcomma{line_width} @mrefcomma{key}
5197 @mref{line_type} and @code{color}.
5202 (%i1) draw2d(color = "#e245f0",
5204 polygon([[3,2],[7,2],[5,5]]),
5206 fill_color = yellow,
5207 polygon([[5,2],[9,2],[7,5]]) )$
5209 @figure{draw_polygon}
5211 @opencatbox{Categories:}
5212 @category{Package draw}
5218 @anchor{quadrilateral}
5219 @deffn {Graphic object} quadrilateral (@var{point_1}, @var{point_2}, @var{point_3}, @var{point_4})
5220 Draws a quadrilateral.
5224 @code{quadrilateral([@var{x1}, @var{y1}], [@var{x2}, @var{y2}],
5225 [@var{x3}, @var{y3}], [@var{x4}, @var{y4}])} draws a quadrilateral with vertices
5226 @code{[@var{x1}, @var{y1}]}, @code{[@var{x2}, @var{y2}]},
5227 @code{[@var{x3}, @var{y3}]}, and @code{[@var{x4}, @var{y4}]}.
5229 This object is affected by the following @i{graphic options}:@*
5230 @mrefcomma{transparent} @mrefcomma{fill_color} @mrefcomma{border} @mrefcomma{line_width}
5231 @mrefcomma{key} @mrefcomma{xaxis_secondary} @mrefcomma{yaxis_secondary} @mrefcomma{line_type}
5232 @code{transform} and @code{color}.
5238 quadrilateral([1,1],[2,2],[3,-1],[2,-2]))$
5240 @figure{draw_quadrilateral}
5244 @code{quadrilateral([@var{x1}, @var{y1}, @var{z1}], [@var{x2}, @var{y2},
5245 @var{z2}], [@var{x3}, @var{y3}, @var{z3}], [@var{x4}, @var{y4}, @var{z4}])}
5246 draws a quadrilateral with vertices @code{[@var{x1}, @var{y1}, @var{z1}]},
5247 @code{[@var{x2}, @var{y2}, @var{z2}]}, @code{[@var{x3}, @var{y3}, @var{z3}]},
5248 and @code{[@var{x4}, @var{y4}, @var{z4}]}.
5250 This object is affected by the following @i{graphic options}: @mrefcomma{line_type}
5251 @mrefcomma{line_width} @mrefcomma{color} @mrefcomma{key} @mref{enhanced3d} and
5254 @opencatbox{Categories:}
5255 @category{Package draw}
5260 @deffn {Graphic object} rectangle ([@var{x1},@var{y1}], [@var{x2},@var{y2}])
5261 Draws rectangles in 2D.
5265 @code{rectangle ([@var{x1},@var{y1}], [@var{x2},@var{y2}])} draws a rectangle with opposite vertices
5266 @code{[@var{x1},@var{y1}]} and @code{[@var{x2},@var{y2}]}.
5268 This object is affected by the following @i{graphic options}: @mrefcomma{transparent}
5269 @mrefcomma{fill_color} @mrefcomma{border} @mrefcomma{line_width} @mrefcomma{key}
5270 @mref{line_type} and @code{color}.
5275 (%i1) draw2d(fill_color = red,
5278 transparent = false,
5280 rectangle([-2,-2],[8,-1]), /* opposite vertices */
5284 rectangle([9,4],[2,-1.5]),
5286 yrange = [-3,4.5] )$
5288 @figure{draw_rectangle}
5290 @opencatbox{Categories:}
5291 @category{Package draw}
5300 @deffn {Graphic object} region (@var{expr},@var{var1},@var{minval1},@var{maxval1},@var{var2},@var{minval2},@var{maxval2})
5301 Plots a region on the plane defined by inequalities.
5304 @var{expr} is an expression formed by inequalities and boolean operators
5305 @code{and}, @code{or}, and @mrefdot{not} The region is bounded by the rectangle
5306 defined by @math{[@var{minval1}, @var{maxval1}]} and @math{[@var{minval2}, @var{maxval2}]}.
5308 This object is affected by the following @i{graphic options}: @mrefcomma{fill_color}
5309 @mrefcomma{key} @mref{x_voxel} and @mrefdot{y_voxel}
5317 region(x^2+y^2<1 and x^2+y^2 > 1/2,
5318 x, -1.5, 1.5, y, -1.5, 1.5));
5321 @figure{draw_region}
5325 @deffn {Graphic object} spherical (@var{radius}, @var{azi}, @var{minazi}, @var{maxazi}, @var{zen}, @var{minzen}, @var{maxzen})
5326 Draws 3D functions defined in spherical coordinates.
5330 @code{spherical(@var{radius}, @var{azi}, @var{minazi}, @var{maxazi}, @var{zen},
5331 @var{minzen}, @var{maxzen})} plots the function @code{@var{radius}(@var{azi},
5332 @var{zen})} defined in spherical coordinates, with @i{azimuth} @var{azi} taking
5333 values from @var{minazi} to @var{maxazi} and @i{zenith} @var{zen} taking values
5334 from @var{minzen} to @var{maxzen}.
5336 This object is affected by the following @i{graphic options}: @mrefcomma{xu_grid}
5337 @mrefcomma{yv_grid} @mrefcomma{line_type} @mrefcomma{key} @mrefcomma{wired_surface} @mref{enhanced3d} and @code{color}.
5342 (%i1) draw3d(spherical(1,a,0,2*%pi,z,0,%pi))$
5344 @figure{draw_spherical}
5346 @opencatbox{Categories:}
5347 @category{Package draw}
5354 @deffn {Graphic object} triangle (@var{point_1}, @var{point_2}, @var{point_3})
5359 @code{triangle ([@var{x1},@var{y1}], [@var{x2},@var{y2}], [@var{x3},@var{y3}])} draws a triangle with vertices @code{[@var{x1},@var{y1}]}, @code{[@var{x2},@var{y2}]},
5360 and @code{[@var{x3},@var{y3}]}.
5362 This object is affected by the following @i{graphic options}:@*
5363 @mrefcomma{transparent} @mrefcomma{fill_color} @mrefcomma{border} @mrefcomma{line_width}
5364 @mrefcomma{key} @mrefcomma{xaxis_secondary} @mrefcomma{yaxis_secondary} @mrefcomma{line_type}
5365 @mref{transform} and @code{color}.
5371 triangle([1,1],[2,2],[3,-1]))$
5373 @figure{draw_triangle}
5377 @code{triangle ([@var{x1},@var{y1},@var{z1}], [@var{x2},@var{y2},@var{z2}], [@var{x3},@var{y3},@var{z3}])} draws a triangle with vertices @code{[@var{x1},@var{y1},@var{z1}]},
5378 @code{[@var{x2},@var{y2},@var{z2}]}, and @code{[@var{x3},@var{y3},@var{z3}]}.
5380 This object is affected by the following @i{graphic options}: @mrefcomma{line_type}
5381 @mrefcomma{line_width} @mrefcomma{color} @mrefcomma{key} @mref{enhanced3d} and @mrefdot{transform}
5383 @opencatbox{Categories:}
5384 @category{Package draw}
5391 @deffn {Graphic object} tube (@var{xfun},@var{yfun},@var{zfun},@var{rfun},@var{p},@var{pmin},@var{pmax})
5392 Draws a tube in 3D with varying diameter.
5396 @code{[@var{xfun},@var{yfun},@var{zfun}]}
5397 is the parametric curve with parameter @var{p} taking values from @var{pmin}
5398 to @var{pmax}. Circles of radius @var{rfun} are placed with their centers on
5399 the parametric curve and perpendicular to it.
5401 This object is affected by the following @i{graphic options}: @mrefcomma{xu_grid}
5402 @mrefcomma{yv_grid} @mrefcomma{line_type} @mrefcomma{line_width} @mrefcomma{key} @mrefcomma{wired_surface} @mrefcomma{enhanced3d}
5403 @mref{color} and @mrefdot{capping}
5411 tube(cos(a), a, 0, cos(a/10)^2,
5416 @opencatbox{Categories:}
5417 @category{Package draw}
5425 @deffn {Graphic object} vector @
5426 @fname{vector} ([@var{x},@var{y}], [@var{dx},@var{dy}]) @
5427 @fname{vector} ([@var{x},@var{y},@var{z}], [@var{dx},@var{dy},@var{dz}])
5429 Draws vectors in 2D and 3D.
5431 This object is affected by the following @i{graphic options}: @mrefcomma{head_both}
5432 @mrefcomma{head_length} @mrefcomma{head_angle} @mrefcomma{head_type} @mrefcomma{line_width}
5433 @mrefcomma{line_type} @mref{key} and @code{color}.
5437 @code{vector([@var{x},@var{y}], [@var{dx},@var{dy}])} plots vector
5438 @code{[@var{dx},@var{dy}]} with origin in @code{[@var{x},@var{y}]}.
5443 (%i1) draw2d(xrange = [0,12],
5446 vector([0,1],[5,5]), /* default type */
5448 vector([3,1],[5,5]),
5450 head_type = 'nofilled,
5452 vector([6,1],[5,5]))$
5454 @figure{draw_vector}
5458 @code{vector([@var{x},@var{y},@var{z}], [@var{dx},@var{dy},@var{dz}])}
5459 plots vector @code{[@var{dx},@var{dy},@var{dz}]} with
5460 origin in @code{[@var{x},@var{y},@var{z}]}.
5465 (%i1) draw3d(color = cyan,
5466 vector([0,0,0],[1,1,1]/sqrt(3)),
5467 vector([0,0,0],[1,-1,0]/sqrt(2)),
5468 vector([0,0,0],[1,1,-2]/sqrt(6)) )$
5470 @figure{draw_vector2}
5472 @opencatbox{Categories:}
5473 @category{Package draw}
5478 @anchor{draw_renderer}
5479 @defvr {Variable} draw_renderer
5480 @c gnuplot_pipes is the default value here, it might also be gnuplot?
5481 Default value: @code{gnuplot_pipes}
5483 When @code{draw_renderer} is set to @code{'vtk}, the VTK interface is used for draw.
5485 @opencatbox{Categories:}
5486 @category{Package draw}
5494 @node Functions and Variables for pictures, Functions and Variables for worldmap, Functions and Variables for draw, draw-pkg
5495 @section Functions and Variables for pictures
5500 @deffn {Function} get_pixel (@var{pic},@var{x},@var{y})
5501 Returns pixel from picture. Coordinates @var{x} and @var{y} range from 0 to
5502 @code{width-1} and @code{height-1}, respectively.
5504 @opencatbox{Categories:}
5505 @category{Package draw}
5513 @anchor{make_level_picture}
5514 @deffn {Function} make_level_picture @
5515 @fname{make_level_picture} (@var{data}) @
5516 @fname{make_level_picture} (@var{data},@var{width},@var{height})
5518 Returns a levels @var{picture} object. @code{make_level_picture (@var{data})}
5519 builds the @var{picture} object from matrix @var{data}.
5520 @code{make_level_picture (@var{data},@var{width},@var{height})}
5521 builds the object from a list of numbers; in this case, both the
5522 @var{width} and the @var{height} must be given.
5524 The returned @var{picture} object contains the following
5528 @item symbol @code{level}
5531 @item an integer array with pixel data ranging from 0 to 255.
5532 Argument @var{data} must contain only numbers ranged from 0 to 255;
5533 negative numbers are substituted by 0, and those which are
5534 greater than 255 are set to 255.
5539 Level picture from matrix.
5541 (%i1) make_level_picture(matrix([3,2,5],[7,-9,3000]));
5542 (%o1) picture(level, 3, 2, @{Array: #(3 2 5 7 0 255)@})
5545 Level picture from numeric list.
5547 (%i1) make_level_picture([-2,0,54,%pi],2,2);
5548 (%o1) picture(level, 2, 2, @{Array: #(0 0 54 3)@})
5551 @opencatbox{Categories:}
5552 @category{Package draw}
5560 @anchor{make_rgb_picture}
5561 @deffn {Function} make_rgb_picture (@var{redlevel},@var{greenlevel},@var{bluelevel})
5562 Returns an rgb-coloured @var{picture} object. All three arguments must
5563 be levels picture; with red, green and blue levels.
5565 The returned @var{picture} object contains the following
5569 @item symbol @code{rgb}
5572 @item an integer array of length @var{3*width*height} with pixel data ranging
5573 from 0 to 255. Each pixel is represented by three consecutive numbers
5580 (%i1) red: make_level_picture(matrix([3,2],[7,260]));
5581 (%o1) picture(level, 2, 2, @{Array: #(3 2 7 255)@})
5582 (%i2) green: make_level_picture(matrix([54,23],[73,-9]));
5583 (%o2) picture(level, 2, 2, @{Array: #(54 23 73 0)@})
5584 (%i3) blue: make_level_picture(matrix([123,82],[45,32.5698]));
5585 (%o3) picture(level, 2, 2, @{Array: #(123 82 45 33)@})
5586 (%i4) make_rgb_picture(red,green,blue);
5587 (%o4) picture(rgb, 2, 2,
5588 @{Array: #(3 54 123 2 23 82 7 73 45 255 0 33)@})
5591 @opencatbox{Categories:}
5592 @category{Package draw}
5601 @anchor{negative_picture}
5602 @deffn {Function} negative_picture (@var{pic})
5603 Returns the negative of a (@var{level} or @var{rgb}) picture.
5605 @opencatbox{Categories:}
5606 @category{Package draw}
5614 @anchor{picture_equalp}
5615 @deffn {Function} picture_equalp (@var{x},@var{y})
5616 Returns @code{true} in case of equal pictures, and @code{false} otherwise.
5618 @opencatbox{Categories:}
5619 @category{Package draw}
5620 @category{Predicate functions}
5629 @deffn {Function} picturep (@var{x})
5630 Returns @code{true} if the argument is a well formed image,
5631 and @code{false} otherwise.
5633 @opencatbox{Categories:}
5634 @category{Package draw}
5635 @category{Predicate functions}
5643 @deffn {Function} read_xpm (@var{xpm_file})
5644 Reads a file in xpm and returns a picture object.
5646 @opencatbox{Categories:}
5647 @category{Package draw}
5656 @deffn {Function} rgb2level (@var{pic})
5657 Transforms an @var{rgb} picture into a @var{level} one by
5658 averaging the red, green and blue channels.
5660 @opencatbox{Categories:}
5661 @category{Package draw}
5669 @anchor{take_channel}
5670 @deffn {Function} take_channel (@var{im},@var{color})
5671 If argument @var{color} is @code{red}, @code{green} or @code{blue},
5672 function @code{take_channel} returns the corresponding color channel of
5677 (%i1) red: make_level_picture(matrix([3,2],[7,260]));
5678 (%o1) picture(level, 2, 2, @{Array: #(3 2 7 255)@})
5679 (%i2) green: make_level_picture(matrix([54,23],[73,-9]));
5680 (%o2) picture(level, 2, 2, @{Array: #(54 23 73 0)@})
5681 (%i3) blue: make_level_picture(matrix([123,82],[45,32.5698]));
5682 (%o3) picture(level, 2, 2, @{Array: #(123 82 45 33)@})
5683 (%i4) make_rgb_picture(red,green,blue);
5684 (%o4) picture(rgb, 2, 2,
5685 @{Array: #(3 54 123 2 23 82 7 73 45 255 0 33)@})
5686 (%i5) take_channel(%,'green); /* simple quote!!! */
5687 (%o5) picture(level, 2, 2, @{Array: #(54 23 73 0)@})
5690 @opencatbox{Categories:}
5691 @category{Package draw}
5700 @node Functions and Variables for worldmap, , Functions and Variables for pictures, draw-pkg
5701 @section Functions and Variables for worldmap
5703 @subsection Variables and Functions
5707 @anchor{boundaries_array}
5708 @defvr {Global variable} boundaries_array
5709 Default value: @code{false}
5711 @code{boundaries_array} is where the graphic object @code{geomap} looks
5712 for boundaries coordinates.
5714 Each component of @code{boundaries_array} is an array of floating
5715 point quantities, the coordinates of a polygonal segment or map boundary.
5717 See also @mrefdot{geomap}
5719 @opencatbox{Categories:}
5720 @category{Package draw}
5729 @anchor{numbered_boundaries}
5730 @deffn {Function} numbered_boundaries (@var{nlist})
5731 Draws a list of polygonal segments (boundaries), labeled by
5732 its numbers (@code{boundaries_array} coordinates). This is of great
5733 help when building new geographical entities.
5737 Map of Europe labeling borders with their component number in
5738 @code{boundaries_array}.
5740 (%i1) load(worldmap)$
5741 (%i2) european_borders:
5742 region_boundaries(-31.81,74.92,49.84,32.06)$
5743 (%i3) numbered_boundaries(european_borders)$
5746 @opencatbox{Categories:}
5747 @category{Package draw}
5755 @anchor{make_poly_continent}
5756 @deffn {Function} make_poly_continent @
5757 @fname{make_poly_continent} (@var{continent_name}) @
5758 @fname{make_poly_continent} (@var{country_list})
5760 Makes the necessary polygons to draw a colored continent
5761 or a list of countries.
5766 (%i1) load(worldmap)$
5767 (%i2) /* A continent */
5768 make_poly_continent(Africa)$
5769 (%i3) apply(draw2d, %)$
5771 @figure{worldmap_make_poly_continent}
5773 (%i4) /* A list of countries */
5774 make_poly_continent([Germany,Denmark,Poland])$
5775 (%i5) apply(draw2d, %)$
5777 @figure{worldmap_make_poly_continent2}
5779 @opencatbox{Categories:}
5780 @category{Package draw}
5789 @anchor{make_poly_country}
5790 @deffn {Function} make_poly_country (@var{country_name})
5791 Makes the necessary polygons to draw a colored country.
5792 If islands exist, one country can be defined with more than
5798 (%i1) load(worldmap)$
5799 (%i2) make_poly_country(India)$
5800 (%i3) apply(draw2d, %)$
5802 @figure{worldmap_make_poly_country}
5804 @opencatbox{Categories:}
5805 @category{Package draw}
5814 @anchor{make_polygon}
5815 @deffn {Function} make_polygon (@var{nlist})
5816 Returns a @code{polygon} object from boundary indices. Argument
5817 @var{nlist} is a list of components of @code{boundaries_array}.
5821 Bhutan is defined by boundary numbers 171, 173
5822 and 1143, so that @code{make_polygon([171,173,1143])}
5823 appends arrays of coordinates @code{boundaries_array[171]},
5824 @code{boundaries_array[173]} and @code{boundaries_array[1143]} and
5825 returns a @code{polygon} object suited to be plotted by
5826 @code{draw}. To avoid an error message, arrays must be
5827 compatible in the sense that any two consecutive
5828 arrays have two coordinates in the extremes in common. In this
5829 example, the two first components of @code{boundaries_array[171]} are
5830 equal to the last two coordinates of @code{boundaries_array[173]}, and
5831 the two first of @code{boundaries_array[173]} are equal to the two first
5832 of @code{boundaries_array[1143]}; in conclusion, boundary numbers
5833 171, 173 and 1143 (in this order) are compatible and the colored
5834 polygon can be drawn.
5836 (%i1) load(worldmap)$
5838 (%o2) [[171, 173, 1143]]
5839 (%i3) boundaries_array[171];
5841 #(88.750549 27.14727 88.806351 27.25305 88.901367 27.282221
5842 88.917877 27.321039)@}
5843 (%i4) boundaries_array[173];
5845 #(91.659554 27.76511 91.6008 27.66666 91.598022 27.62499
5846 91.631348 27.536381 91.765533 27.45694 91.775253 27.4161
5847 92.007751 27.471939 92.11441 27.28583 92.015259 27.168051
5848 92.015533 27.08083 92.083313 27.02277 92.112183 26.920271
5849 92.069977 26.86194 91.997192 26.85194 91.915253 26.893881
5850 91.916924 26.85416 91.8358 26.863331 91.712479 26.799999
5851 91.542191 26.80444 91.492188 26.87472 91.418854 26.873329
5852 91.371353 26.800831 91.307457 26.778049 90.682457 26.77417
5853 90.392197 26.903601 90.344131 26.894159 90.143044 26.75333
5854 89.98996 26.73583 89.841919 26.70138 89.618301 26.72694
5855 89.636093 26.771111 89.360786 26.859989 89.22081 26.81472
5856 89.110237 26.829161 88.921631 26.98777 88.873016 26.95499
5857 88.867737 27.080549 88.843307 27.108601 88.750549
5859 (%i5) boundaries_array[1143];
5861 #(91.659554 27.76511 91.666924 27.88888 91.65831 27.94805
5862 91.338028 28.05249 91.314972 28.096661 91.108856 27.971109
5863 91.015808 27.97777 90.896927 28.05055 90.382462 28.07972
5864 90.396088 28.23555 90.366074 28.257771 89.996353 28.32333
5865 89.83165 28.24888 89.58609 28.139999 89.35997 27.87166
5866 89.225517 27.795 89.125793 27.56749 88.971077 27.47361
5867 88.917877 27.321039)@}
5868 (%i6) Bhutan_polygon: make_polygon([171,173,1143])$
5869 (%i7) draw2d(Bhutan_polygon)$
5871 @figure{worldmap_make_polygon}
5873 @opencatbox{Categories:}
5874 @category{Package draw}
5883 @anchor{region_boundaries}
5884 @deffn {Function} region_boundaries (@var{x1},@var{y1},@var{x2},@var{y2})
5885 Detects polygonal segments of global variable @code{boundaries_array}
5886 fully contained in the rectangle with vertices (@var{x1},@var{y1}) -upper left-
5887 and (@var{x2},@var{y2}) -bottom right-.
5891 Returns segment numbers for plotting southern Italy.
5893 (%i1) load(worldmap)$
5894 (%i2) region_boundaries(10.4,41.5,20.7,35.4);
5895 (%o2) [1846, 1863, 1864, 1881, 1888, 1894]
5896 (%i3) draw2d(geomap(%))$
5898 @figure{worldmap_region_boundaries}
5900 @opencatbox{Categories:}
5901 @category{Package draw}
5908 @anchor{region_boundaries_plus}
5909 @deffn {Function} region_boundaries_plus (@var{x1},@var{y1},@var{x2},@var{y2})
5910 Detects polygonal segments of global variable @code{boundaries_array}
5911 containing at least one vertex in the rectangle defined by vertices (@var{x1},@var{y1})
5912 -upper left- and (@var{x2},@var{y2}) -bottom right-.
5917 (%i1) load(worldmap)$
5918 (%i2) region_boundaries_plus(10.4,41.5,20.7,35.4);
5919 (%o2) [1060, 1062, 1076, 1835, 1839, 1844, 1846, 1858,
5920 1861, 1863, 1864, 1871, 1881, 1888, 1894, 1897]
5921 (%i3) draw2d(geomap(%))$
5923 @figure{worldmap_region_boundaries_plus}
5925 @opencatbox{Categories:}
5926 @category{Package draw}
5934 @subsection Graphic objects
5938 @deffn {Graphic object} geomap @
5939 @fname{geomap} (@var{numlist}) @
5940 @fname{geomap} (@var{numlist},@var{3Dprojection})
5942 Draws cartographic maps in 2D and 3D.
5946 This function works together with global variable @code{boundaries_array}.
5948 Argument @var{numlist} is a list containing numbers or lists of numbers.
5949 All these numbers must be integers greater or equal than zero,
5950 representing the components of global array @code{boundaries_array}.
5952 Each component of @code{boundaries_array} is an array of floating
5953 point quantities, the coordinates of a polygonal segment or map boundary.
5955 @code{geomap (@var{numlist})} flattens its arguments and draws the
5956 associated boundaries in @code{boundaries_array}.
5958 This object is affected by the following @i{graphic options}: @mrefcomma{line_width}
5959 @mref{line_type} and @code{color}.
5963 A simple map defined by hand:
5965 (%i1) load(worldmap)$
5966 (%i2) /* Vertices of boundary #0: @{(1,1),(2,5),(4,3)@} */
5967 ( bnd0: make_array(flonum,6),
5968 bnd0[0]:1.0, bnd0[1]:1.0, bnd0[2]:2.0,
5969 bnd0[3]:5.0, bnd0[4]:4.0, bnd0[5]:3.0 )$
5970 (%i3) /* Vertices of boundary #1: @{(4,3),(5,4),(6,4),(5,1)@} */
5971 ( bnd1: make_array(flonum,8),
5972 bnd1[0]:4.0, bnd1[1]:3.0, bnd1[2]:5.0, bnd1[3]:4.0,
5973 bnd1[4]:6.0, bnd1[5]:4.0, bnd1[6]:5.0, bnd1[7]:1.0)$
5974 (%i4) /* Vertices of boundary #2: @{(5,1), (3,0), (1,1)@} */
5975 ( bnd2: make_array(flonum,6),
5976 bnd2[0]:5.0, bnd2[1]:1.0, bnd2[2]:3.0,
5977 bnd2[3]:0.0, bnd2[4]:1.0, bnd2[5]:1.0 )$
5978 (%i5) /* Vertices of boundary #3: @{(1,1), (4,3)@} */
5979 ( bnd3: make_array(flonum,4),
5980 bnd3[0]:1.0, bnd3[1]:1.0, bnd3[2]:4.0, bnd3[3]:3.0)$
5981 (%i6) /* Vertices of boundary #4: @{(4,3), (5,1)@} */
5982 ( bnd4: make_array(flonum,4),
5983 bnd4[0]:4.0, bnd4[1]:3.0, bnd4[2]:5.0, bnd4[3]:1.0)$
5984 (%i7) /* Pack all together in boundaries_array */
5985 ( boundaries_array: make_array(any,5),
5986 boundaries_array[0]: bnd0, boundaries_array[1]: bnd1,
5987 boundaries_array[2]: bnd2, boundaries_array[3]: bnd3,
5988 boundaries_array[4]: bnd4 )$
5989 (%i8) draw2d(geomap([0,1,2,3,4]))$
5991 @figure{worldmap_geomap}
5993 The auxiliary package @code{worldmap} sets the global variable
5994 @code{boundaries_array} to real world boundaries in
5995 (longitude, latitude) coordinates. These data are in the
5996 public domain and come from
5997 @c Link is dead, linked to archive.org. Does someone know a better Link?
5998 @url{https://web.archive.org/web/20100310124019/http://www-cger.nies.go.jp/grid-e/gridtxt/grid19.html}.
5999 Package @code{worldmap} defines also boundaries for countries,
6000 continents and coastlines as lists with the necessary components of
6001 @code{boundaries_array} (see file @code{share/draw/worldmap.mac}
6002 for more information). Package @code{worldmap} automatically loads
6003 package @code{worldmap}.
6005 (%i1) load(worldmap)$
6006 (%i2) c1: gr2d(geomap([Canada,United_States,
6008 (%i3) c2: gr2d(geomap(Africa))$
6009 (%i4) c3: gr2d(geomap([Oceania,China,Japan]))$
6010 (%i5) c4: gr2d(geomap([France,Portugal,Spain,
6011 Morocco,Western_Sahara]))$
6012 (%i6) draw(columns = 2,
6015 @figure{worldmap_geomap2}
6017 Package @code{worldmap} is also useful for plotting
6018 countries as polygons. In this case, graphic object
6019 @code{geomap} is no longer necessary and the @code{polygon}
6020 object is used instead. Since lists are now used and not
6021 arrays, maps rendering will be slower. See also @mref{make_poly_country}
6022 and @mref{make_poly_continent} to understand the following code.
6024 (%i1) load(worldmap)$
6025 (%i2) mymap: append(
6026 [color = white], /* borders are white */
6027 [fill_color = red], make_poly_country(Bolivia),
6028 [fill_color = cyan], make_poly_country(Paraguay),
6029 [fill_color = green], make_poly_country(Colombia),
6030 [fill_color = blue], make_poly_country(Chile),
6031 [fill_color = "#23ab0f"], make_poly_country(Brazil),
6032 [fill_color = goldenrod], make_poly_country(Argentina),
6033 [fill_color = "midnight-blue"], make_poly_country(Uruguay))$
6034 (%i3) apply(draw2d, mymap)$
6036 @figure{worldmap_geomap3}
6041 @code{geomap (@var{numlist})} projects map boundaries on the sphere of radius 1
6042 centered at (0,0,0). It is possible to change the sphere or the projection type
6043 by using @code{geomap (@var{numlist},@var{3Dprojection})}.
6045 Available 3D projections:
6049 @code{[spherical_projection,@var{x},@var{y},@var{z},@var{r}]}: projects map boundaries on the sphere of
6050 radius @var{r} centered at (@var{x},@var{y},@var{z}).
6052 (%i1) load(worldmap)$
6053 (%i2) draw3d(geomap(Australia), /* default projection */
6055 [spherical_projection,2,2,2,3]))$
6057 @figure{worldmap_geomap4}
6060 @code{[cylindrical_projection,@var{x},@var{y},@var{z},@var{r},@var{rc}]}: re-projects spherical map boundaries on the cylinder of radius
6061 @var{rc} and axis passing through the poles of the globe of radius @var{r} centered at (@var{x},@var{y},@var{z}).
6063 (%i1) load(worldmap)$
6064 (%i2) draw3d(geomap([America_coastlines,Eurasia_coastlines],
6065 [cylindrical_projection,2,2,2,3,4]))$
6067 @figure{worldmap_geomap5}
6070 @code{[conic_projection,@var{x},@var{y},@var{z},@var{r},@var{alpha}]}: re-projects spherical map boundaries on the cones of angle @var{alpha},
6071 with axis passing through the poles of the globe of radius @var{r} centered at (@var{x},@var{y},@var{z}). Both
6072 the northern and southern cones are tangent to sphere.
6074 (%i1) load(worldmap)$
6075 (%i2) draw3d(geomap(World_coastlines,
6076 [conic_projection,0,0,0,1,90]))$
6079 @figure{worldmap_geomap6}
6081 See also @url{http://riotorto.users.sf.net/gnuplot/geomap}
6082 for more elaborated examples.
6084 @opencatbox{Categories:}
6085 @category{Package draw}