CoCalc Public FilesNewer Stuff / Newer Bits of the Graphical Appendix / comparing_old_and_new.sagewsOpen with one click!
Authors: Gregory Bard, Jack Kennedy, Harald Schilly
Views : 40
Compute Environment: Ubuntu 18.04 (Deprecated)

The current undesirable behavior of plot3d

var("x y z") plot3d( x^2 + y^3, (x,-3,3), (y,-3,3) )
(x, y, z)
3D rendering not yet implemented
var("x y") plot3d( 1/( (x-2)^2 + (y-1)^2 ), (x,-3,3), (y,-3,3) )
(x, y)
3D rendering not yet implemented

Now, the behavior of the new code that I've written

%load new_plot3d_syntax.sage
newPlot3d( x^2 + y^3, -3,3, -3,3, -4,4 )
<string>:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See for details.
3D rendering not yet implemented
newPlot3d( 1/( (x-2)^2 + (y-1)^2 ), -3,3, -3,3, 0,6 )
3D rendering not yet implemented

What are some of the changes?

  • Functions with vertical asymptotes were not graphable at all before
    • Before, you'd get something that looks like a vertical pencil.
    • Now they can be graphed like any other function.
  • Before, you could not bound the desired z-coordinates at all
    • Now such bounds are obligatory.
    • This is what allows for functions with vertical asymptotes.
  • Before, the aspect ratio defaults to [1,1,1]
    • Now, the aspect ratio is computed for the user so as to produce a graph in a cube.
    • Many images, in the old code, were hard to interpret/understand because of the aspect ratios.
    • The aspect ratio requires knowledge of the bounds of the function.
      • I don't think a student at the start of learning about 3D functions can compute those bounds unassisted.
      • Yet, without those bounds, the aspect ratio to produce a cube cannot be computed.
      • And without the aspect ratios being provided by the user in the old code, the image is unreadable.
      • Therefore, with the current commands, newbie users cannot just sit down and graph in 3D.
    • You can always override the default aspect ratios, in either case, by an option.
  • Before the mesh defaults to "off", but you can turn it on with an option.
    • Now the mesh defaults to "on", but you can turn it off with an option.
sage: from sage.plot.plot3d.implicit_surface import ImplicitSurface %var x,y,z contour=[-1, 0, 1, 2] from numpy import linspace where = linspace(min(contour), max(contour), len(contour)) / (max(contour) - min(contour)) where -= where[0] colors = [colormaps.coolwarm(i) for i in where] sum(implicit_plot3d( 1/( (x-2)^2 + (y-1)^2 ) == z, (x,-3, 3), (y,-3, 3), (z, -1, 6), contour=con, color=col, mesh=True) for con, col in zip(contour, colors))
3D rendering not yet implemented
implicit_plot3d( 1/( (x-2)^2 + (y-1)^2 ) == z, (x,-3, 3), (y,-3, 3), (z, 0, 6), mesh=True, color='green')
3D rendering not yet implemented