All published worksheets from http://sagenb.org
Image: ubuntu2004
File: /usr/local/sage2/local/lib/python2.6/site-packages/sage/plot/plot.py
Type: <type ‘function’>
Definition: list_plot(data, plotjoined=False, **kwargs)
Docstring:
list_plot takes either a single list of data, a list of tuples, or a dictionary and plots the corresponding points.
If given a single list of data, list_plot forms a list of tuples (i,di) where i goes from 0 to { len}(data)-1 and di is the i^{th} data value, and puts points at those tuple values.
list_plot also takes a list of tuples (dxi, dyi) where dxi is the i^{th} data representing the x-value, and dyi is the i^{th} y-value. If plotjoined=True , then a line spanning all the data is drawn instead.
If given a dictionary, list_plot interprets the keys as x-values and the values as y-values.
EXAMPLES:
sage: list_plot([i^2 for i in range(5)])Here are a bunch of random red points:
sage: r = [(random(),random()) for _ in range(20)] sage: list_plot(r,color='red')This gives all the random points joined in a purple line:
sage: list_plot(r, plotjoined=True, color='purple')If you have separate lists of x values and y values which you want to plot against each other, use the zip command to make a single list whose entries are pairs of (x,y) values, and feed the result into list_plot:
sage: x_coords = [cos(t)^3 for t in srange(0, 2*pi, 0.02)] sage: y_coords = [sin(t)^3 for t in srange(0, 2*pi, 0.02)] sage: list_plot(zip(x_coords, y_coords))If instead you try to pass the two lists as separate arguments, you will get an error message:
sage: list_plot(x_coords, y_coords) ... TypeError: The second argument 'plotjoined' should be boolean (True or False). If you meant to plot two lists 'x' and 'y' against each other, use 'list_plot(zip(x,y))'.Dictionaries with numeric keys and values can be plotted:
sage: list_plot({22: 3365, 27: 3295, 37: 3135, 42: 3020, 47: 2880, 52: 2735, 57: 2550})TESTS:
We check to see that the x/y min/max data are set correctly.
sage: d = list_plot([(100,100), (120, 120)]).get_minmax_data() sage: d['xmin'] 100.0 sage: d['ymin'] 100.0