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
better use: >>> show(p+l,xmax=len(data)-1+offset,**kwargs)
Is this a typical thing used in certain types of data analysis? If so, we could open a ticket for adding something like this - perhaps we could wrap [matplotlib's](http://matplotlib.org/1.2.0/api/pyplot_api.html?highlight=stem#matplotlib.pyplot.stem).
Yes. Used in statistics.
Great, I've made this [Trac 14663](http://trac.sagemath.org/sage_trac/ticket/14663).