Home > Commands -> Plot Options -> show


EXAMPLES ON MY SAGE PAGES: plot - Options and plot3d - Options


Syntax: show(graphics objects, 2d or 3d plot options )

graphics objects are objects created by 2d or 3d commands.

  • show() is used for displaying in a single plot box one or more graphics objects.
  • The objects should be named and "summed", that is, the objects inside the show command are separated by + signs, not commas.
    • I often use the sum command with a list of graphics objects (see ex.3 below)

Example 1 - plot y=2x and the point (2,1)

F=plot(2*x,(x,-2,2))
P=point((3,1), size=20, color='red')
show(F+P, figsize=3)

Example 2 - plot a bunch of 2d stuff - line

P1=point((0, 0), size=40)
L1=line( [ (0, 0), (2, 1) ], color="red", thickness=2 )
L2=line( [ (-1, -2), (1, 2) ], color="purple", thickness=2, linestyle="-.")
PL1=line( [ (3, -2), (0, 0), (3, 2) ], thickness=2, alpha=0.5)
show(P1+L1+L2+PL1, figsize=4)


Example 3

show_arrows.gif

Example 3 - A bit exotic (for me at least), but very useful in visualizing the math

#Problem: Use a line integral to find the work done by the force F=(xy,3z,1) on the vector-parametric curve s=(2cos(t),3sin(t),1)
#This plot "shows" the work is 0 (which we also showed with math).

var ('t'); s=vector((2*cos(t),3*sin(t),1)); t1=0; t2=2*pi
C=parametric_plot3d(s,(t,t1,t2),color='yellow',thickness=5)

vs=2         #regulates the size of the arrows
num=40    #regulates the number arrows
# the start of each arrow is s, the end of the arrow is s+F/vs

vf=sum([arrow3d((2*cos(j),3*sin(j),1),(2*cos(j)+2*cos(j)*3*sin(j)/vs,3*sin(j)+3*1/vs,1+1/vs), color=hue((j+8)/8), width=0.8)
for j in [t1..t2,step=(t2-t1)/num]])

show(C+vf,aspect_ratio=(1,1,pi), figsize=5, frame=False)

Extras

  • 2d
    • If I am desperate to define a minimum box in 2d, I add: Bx=point([(xmin,ymin),(xmax,ymax)], alpha=0) and add it to my show.
  • 3d
    • If I am desperate to define a minimum box in 3d, I add: Bx=point([(xmin,ymin,zmin),(xmax,ymax,zmax)], opacity=0) and add it to my show.

Keywords: show, plot, plot3d, 2d commands, 3d commands