Back to main page
Back to draw contents

Enhanced text

It's possible to write greek letters and some basic mathematical symbols in labels and titles. The syntax to be used is described here.

For some of these examples to work, you need Maxima 5.23 and Gnuplot 4.4.


Greek letters and the integral symbol.

draw2d(
  dimensions = 100*[12, 8], /* 12 cm x 8 cm */
  filled_func = 0,
  fill_color  = cyan,
  explicit(x^2-x+5, x, 1, 4),
  filled_func = false,
  explicit(x^2-x+5, x, -1, 5),
  label(["A = {/Symbol=30 \\362@_{/=9.6 1}^{/=12 4}} ({/Symbol a} x^2 + {/Symbol b} x +{/Symbol g}) d x",1,17]),
  yrange      = [-1,30],
  grid        = true,
  terminal    = eps ) $

Gif animation with greek characters.

set_draw_defaults(
  xrange = [1,2.5],
  yrange = [1,3],
  label_alignment = left )$

greek_word:
  ["{/Symbol P} ",
   "{/Symbol u} ",
   "{/Symbol t} ",
   "{/Symbol a} ",
   "{/Symbol g} ",
   "{/Symbol o} ",
   "{/Symbol r} ",
   "{/Symbol a} ",
   "{/Symbol s} "] $

dynamic_word:
  makelist(
    block([word:""],
      for i:1 thru k do word: concat(word, greek_word[i]),
      gr2d(label([word,1.3,2]))),
    k, 1, length(greek_word)) $

draw(
  delay      = 100,
  file_name  = "greek",
  dimensions = [400, 200],
  terminal   = 'animated_gif,
  dynamic_word  )$

Mathematical expressions in a png file.

draw2d(
  terminal  = png,
  explicit(exp(-tau^2/2),tau,0,1),
  ylabel = "f({/Symbol t})",
  xlabel = "Time,  {/Symbol t}",
  label(["f({/Symbol t}) = e^{-{/Symbol t}^2/2}",0.3,0.7]) ) $

With next Maxima 5.30, or current repository draw package, it will be possible to write LaTeX code in titles, labels, axes tics and axes labels, when working with terminal = epslatex_standalone.

load(distrib) $

/* This code generates two files: maxima_out.tex and maxima_out-inc.eps */
draw(
    terminal = epslatex_standalone,
    dimensions = 100*[12,8],

    gr2d(title      = "Standard Gaussian distribution, $\\Phi(x)$",
         ylabel     = "$\\Phi(x) = \\Pr\\{ X \\leq x\\}$",
         xtics      = {["$\\longleftarrow -\\infty$", -2.5], ["0",0], ["$x=1$",1]},
         grid       = true,
         line_width = 2,
         key        = "$\\Phi$",
         explicit(cdf_normal(x, 0, 1), x, -3, 3),
         label(["$\\Phi(x)=\\int_{-\\infty}^x \\phi(u) du=\\int_{-\\infty}^x \\frac{1}{\\sqrt{2 \\pi}}e^{-\\frac{u^2}{2}}du$", 0, 0.25]),
         points_joined = impulses,
         color         = red,
         line_width    = 6,
         key           = "$\\Pr\\{X \\leq 1\\}$",
         points([[1, cdf_normal(1, 0, 1)]])),

    gr2d(allocation  = [[0.1,0.4], [0.5,0.5]],
         title       = "Gaussian density, $\\phi(x)$",
         ytics       = {["$\\frac{1}{20}$",5/100], ["$\\frac{4}{20}$",20/100], ["$\\frac{7}{20}$",35/100]},
         line_width  = 2,
         filled_func = true,
         fill_color  = light_gray,
         explicit(pdf_normal(x,0,1),x,-3,1),
         filled_func = false,
         color       = blue,
         explicit(pdf_normal(x,0,1),x,-3,3) ) ) $

/* Linux command to generate the plot in dvi format */
system("latex maxima_out.tex") $

/* Linux command to generate the plot in Postscript format */
system("dvips maxima_out.dvi -o") $

Back to main page
Back to draw contents


by Mario Rodríguez Riotorto