Ask Your Question

farnzworld's profile - activity

2017-09-20 17:21:57 +0200 received badge  Notable Question (source)
2016-07-10 07:10:09 +0200 received badge  Popular Question (source)
2013-05-30 03:25:01 +0200 received badge  Nice Question (source)
2013-05-30 00:07:47 +0200 received badge  Student (source)
2013-05-29 15:13:10 +0200 commented question 2D stem plot

better use: >>> show(p+l,xmax=len(data)-1+offset,**kwargs)

2013-05-29 14:57:50 +0200 asked a question 2D stem plot

Hi, this is not really a question but I come by these days to search for a stem plot, can't find any useful and finally came up with the following solution, I want to share:

def stem(data,offset=0,**kwargs):
p=point([])
l=line([])
for d in range(len(data)):
    p+=point((d+offset,data[d]),size=50)
    l+=line([(d+offset,0),(d+offset,data[d])])
show(p+l,xmax=len(data),**kwargs)

for example:

values=[]
for v in range(0,5):
    values.append(1/4^v)
stem(values,ymax=1,axes_labels=('n','x[n]'))
#or with offset
stem(values,-4,ymax=1,axes_labels=('n','x[n]'))
  • arg1 list of data
  • arg2 gives you the opportunity to adjust the starting point
  • **kwargs passes all following arguments to the show-function