papaya
Class ScatterPlot

java.lang.Object
  extended by papaya.Visuals
      extended by papaya.ScatterPlot
All Implemented Interfaces:
PapayaConstants

public class ScatterPlot
extends Visuals

A simple class to plot x vs y data as a scatter plot. Default is to draw the points as ellipses, but you can also use rectangles, and connect the points with lines.

Author:
Adila Faruk

Field Summary
 boolean asConnectedLines
           
 boolean asEllipses
           
 boolean asRectangles
           
 float bottomBound
          Specifies the space on the bottom, between the plot area and the bounding rectangle.
 boolean drawAxes
          Specifies whether to draw the axes
 boolean drawRectangle
          Specifies whether to draw the bounding rectangle around the plot.
 float leftBound
          Specifies the space on the left between the plot area, and the bounding rectangle.
 float rightBound
          Specifies the space on the right betweent the plot area, and the bounding rectangle.
 float topBound
          Specifies the space on the top, between the plot area and the bounding rectangle.
 boolean[] XYLabels
           
 boolean[] XYTicks
           
 
Fields inherited from class papaya.Visuals
bgColor
 
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
 
Constructor Summary
ScatterPlot(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight)
           
 
Method Summary
 void drawRectangle()
          Draws a rectangle around the plot.
 void drawScatterPlot(float[] _xDat, float[] _yDat, float _sWeight, int _sColor)
          Parent function to plot scatter plot of the data.
 void setDataExtremes(float _minXDat, float _maxXDat, float _minYDat, float _maxYDat)
          Set the minimum/maximum values on the x and y axis to nice numbers.
 
Methods inherited from class papaya.Visuals
drawAxes, drawRect, drawRect, getBottom, getHeight, getLeft, getRight, getTop, getWidth, horizLine, legendHoriz, legendVert, line, mapXData, mapXData, mapYData, mapYData, setBackgroundColor, setHeight, setLeft, setTop, setupFont, setupFont, setWidth, vertLine, writeLabels, writeLabels, writeLabels, writeLabels, writeLabels, writeTitle, xLabels, xLabels, xTicks, yLabels, yLabels, YLines, yTicks
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

asConnectedLines

public boolean asConnectedLines

asRectangles

public boolean asRectangles

asEllipses

public boolean asEllipses

XYLabels

public boolean[] XYLabels

XYTicks

public boolean[] XYTicks

drawRectangle

public boolean drawRectangle
Specifies whether to draw the bounding rectangle around the plot.


drawAxes

public boolean drawAxes
Specifies whether to draw the axes


leftBound

public float leftBound
Specifies the space on the left between the plot area, and the bounding rectangle. That is, the left-most point of the rectangle is given by plotLeft-leftBound.


rightBound

public float rightBound
Specifies the space on the right betweent the plot area, and the bounding rectangle. That is, the right-most point of the rectangle is given by plotLeft+plotWidth+rightBound.


topBound

public float topBound
Specifies the space on the top, between the plot area and the bounding rectangle. That is, the top-most point of the rectangle is given by plotTop - topBound.


bottomBound

public float bottomBound
Specifies the space on the bottom, between the plot area and the bounding rectangle. That is, the bottom-most point of the rectangle is given by plotTop + plotHeight + bottomBound.

Constructor Detail

ScatterPlot

public ScatterPlot(PApplet _theParent,
                   float _plotLeft,
                   float _plotTop,
                   float _plotWidth,
                   float _plotHeight)
Method Detail

setDataExtremes

public void setDataExtremes(float _minXDat,
                            float _maxXDat,
                            float _minYDat,
                            float _maxYDat)
Set the minimum/maximum values on the x and y axis to nice numbers. e.g. 60 instead of 63.183628, 90 instead of 87.1, etc. It'll try do it automatically for you, if you don't set it here, but no guarantees on the result being a nice number. For example, it might go from 61 to 89 instead of 60 to 90.

Parameters:
_minXDat - the minimum x value to use. Set to more than the x data minimum.
_maxXDat - the maximum x value to use. Set to more than the x data maximum.
_minYDat - the minimum y value to use. Set to more than the y data minimum.
_maxYDat - the maximum y value to use. Set to more than the y data maximum.

drawRectangle

public void drawRectangle()
Draws a rectangle around the plot.


drawScatterPlot

public void drawScatterPlot(float[] _xDat,
                            float[] _yDat,
                            float _sWeight,
                            int _sColor)
Parent function to plot scatter plot of the data.

Parameters:
_xDat - x Data array
_yDat - y Data array
_sWeight - stroke weight
_sColor - stroke color


Processing library papaya by Adila Faruk. (C) 2014