Scatter Plots

class sage.plot.scatter_plot.ScatterPlot(xdata, ydata, options)

Bases: sage.plot.primitive.GraphicPrimitive

Scatter plot graphics primitive.

Input consists of two lists/arrays of the same length, whose values give the horizontal and vertical coordinates of each point in the scatter plot. Options may be passed in dictionary format.

EXAMPLES:

sage: from sage.plot.scatter_plot import ScatterPlot
sage: ScatterPlot([0,1,2], [3.5,2,5.1], {'facecolor':'white', 'marker':'s'})
Scatter plot graphics primitive on 3 data points
get_minmax_data()

Returns a dictionary with the bounding box data.

EXAMPLES:

sage: s = scatter_plot([[0,1],[2,4],[3.2,6]])
sage: d = s.get_minmax_data()
sage: d['xmin']
0.0
sage: d['ymin']
1.0
sage.plot.scatter_plot.scatter_plot(datalist, edgecolor='black', facecolor='#fec7b8', clip=True, markersize=50, aspect_ratio='automatic', zorder=5, marker='o', alpha=1, **options)

Returns a Graphics object of a scatter plot containing all points in the datalist. Type scatter_plot.options to see all available plotting options.

INPUT:

  • datalist – a list of tuples (x,y)

  • alpha – default: 1

  • markersize – default: 50

  • marker - The style of the markers (default "o"), which is one of
    • "None" or " " or "" (nothing)
    • "," (pixel), "." (point)
    • "_" (horizontal line), "|" (vertical line)
    • "o" (circle), "p" (pentagon), "s" (square), "x" (x), "+" (plus), "*" (star)
    • "D" (diamond), "d" (thin diamond)
    • "H" (hexagon), "h" (alternative hexagon)
    • "<" (triangle left), ">" (triangle right), "^" (triangle up), "v" (triangle down)
    • "1" (tri down), "2" (tri up), "3" (tri left), "4" (tri right)
    • 0 (tick left), 1 (tick right), 2 (tick up), 3 (tick down)
    • 4 (caret left), 5 (caret right), 6 (caret up), 7 (caret down)
    • "$...$" (math TeX string)
  • facecolor – default: '#fec7b8'

  • edgecolor – default: 'black'

  • zorder – default: 5

EXAMPLES:

sage: scatter_plot([[0,1],[2,2],[4.3,1.1]], marker='s')

Extra options will get passed on to show(), as long as they are valid:

sage: scatter_plot([(0, 0), (1, 1)], markersize=100, facecolor='green', ymax=100)
sage: scatter_plot([(0, 0), (1, 1)], markersize=100, facecolor='green').show(ymax=100) # These are equivalent

Previous topic

Plotting primitives

Next topic

Text in plots

This Page