446 days ago by pub

Wikipages: plot - specifically lists 2d plot options

#Remember that you need to declare any variables used in functions. #We declare the variable x since it is the "standard" variable for explicit 2d functions y=f(x) and we will use it. var ('x') 
# the default figsize=8 and is rather large (I get a 4x3 ratio of pixels: 563x431) # also notice that the aspect_ratio is not 1:1, but is determined by the ranges of values (see way below for more on aspect_ratio) plot(2*x+1,(x,-2,4)) 


#You can define the function separately f(x)=cos(x) plot(f,(x,-pi,pi), figsize=2) 


# To plot more than one function, NAME your plots and then use command show with sum (addition). Notice that the ranges are fixed in the plot commands. g1(x)=x-2 g2(x)=-x+2 P1=plot(g1,(x,-2,2), linestyle="--") P2=plot(g2,(x,2,6), linestyle="-.") show(P1+P2, figsize=4) 


#Remember: alpha is opacity ... plot(f,(x,0,2*pi), figsize=4, color='red', thickness=5, alpha =.5) 


plot(f,(x,0,2*pi), figsize=4, color=(0,.7,0), thickness=3, linestyle='--') 


plot(f,(x,0,2*pi), figsize=4, rgbcolor=(.7,0,.7), thickness=.5) 


# default color='blue', thickness=1, linestyle="-" plot(f,(x,0,2*pi), figsize=4) 


# aspect_ratio: Notice that the aspect_ratio is not quite 1:1 here or above ... plot(exp(-x),(x,0,1),figsize=4) 


# aspect_ratio: Notice that even though we should get a y-stretch of 2, it isn't quite 2. plot(exp(-x),(x,0,1),figsize=4, aspect_ratio=2) 


# to fix the range on y add values for ymin and ymax plot(exp(-x),(x,0,1),figsize=4, ymin=0, ymax=2)