void prepareData() {
		int numPoints = Math.min(MAX_DATA_POINTS, x.length);
		if( x.length > numPoints ) subsample(numPoints);

		// Find min & max values 
		minX = Double.MAX_VALUE;
		maxX = Double.MIN_VALUE;
		minY = Double.MAX_VALUE;
		maxY = Double.MIN_VALUE;
		for( int i = 0; (i < x.length) && (i < numPoints); i++ ) {
			double xx = x[i];
			minX = Math.min(minX, xx);
			maxX = Math.max(maxX, xx);

			double yy = y[i];
			minY = Math.min(minY, yy);
			maxY = Math.max(maxY, yy);
		}

		if( minY == maxY ) minY = 0; // Otherwise the plot does not show anything when the variance is zero

		// Iterate over all sorted keys
		dataList = new ArrayList<Integer>();
		labelList = new ArrayList<String>();
		int labelEvery = Math.max(numPoints / numberLabelsXaxis, 10);
		for( int i = 0; i < numPoints; i++ ) {
			double xx = x[i];

			// Make sure the last point has a coordinate
			if( (i % labelEvery == 0) || (i == (x.length - 1)) || (i == (numPoints - 1)) ) labelList.add(Double.toString(xx));
			else labelList.add("");

			double yy = y[i];
			int scaledY = (int) ((100.0 * (yy - minY)) / (maxY - minY)); // 'Count' scaled form 0 to 100
			dataList.add(scaledY);
		}
	}