Add token placing, axis and title authored by Georg Graßnick's avatar Georg Graßnick
......@@ -23,12 +23,74 @@ In order to separate the axis from the actual plotted data points, a gap of one
The remaining space is used for the actual data representation.
## Example Plot
## Token placing
![scatterplot_example](img/ScatterPlot_example.svg)
![scatterplot_example_legend](img/ScatterPlot_example_legend.svg)
When it comes to the placing of tokens, I decided to only support single dots placed at the positions of data points. When using tokens, which are formed by multiple dots arranged in a texture like formation, the grid of the Braille embosser becomes a significant problem. As the minimum size of distinguishable tokens is 3x3 dots, each token would be split inevitably at the borders of different Braille cells of size 2x3 or 2x4. This would restrict their recognizability.
Due to the limitation to only one type of tokens (single dots), there can be only one data set per document. If the input data (from the CSV file) contains multiple data sets, each data set will be rasterized to a separate document.
The scaling factors are calculated by the ratio of the number of available dots to the value range of the data, using the global maximum and minimum values for bot x y values across all data sets:
``` java
int xDots = plotArea.intWrapper().getWidth() - 1; // The number of available dots - vertical. Subtract 1 to match the internal start index at 0 rather than 1.
int yDots = plotArea.intWrapper().getHeight() - 1; // The number of available dots - horizontal. Subtract 1 to match the internal start index at 0 rather than 1.
double xMin = data.getMinX(); // Global minimum value on x axis
double yMin = data.getMinY(); // Global minimum value on y axis
double xMax = data.getMaxX(); // Global maximum value on x axis
double yMax = data.getMaxY(); // Global maximum value on y axis
double xRange = Math.abs(xMax - xMin); // Absolute Range of x values
double yRange = Math.abs(yMax - yMin); // Absolute Range of y values
double xRatio = ((double) xDots / xRange); // The calculated ratio for the X axis
double yRatio = ((double) yDots / yRange); // The calculated ratio for the y axis
```
Following the ratio calculation, each point is placed by multiplying its x and y values differences to the minimum value with the according ratio:
``` java
for (Point2DDouble p : l) {
int x = (int) Math.round(Math.abs((p.getX() - xMin) * xRatio));
int y = (int) Math.round(Math.abs((p.getY() - yMin) * yRatio));
...
}
```
This results in the minimum value to be placed on dot position `0` and the maximum value to be placed at dot position `xDots` respectively `yDots`.
Each document (one per data set), reuses the global ratios for it's placing of the individual tokens, so that in the end, the pages are comparable. The same applies for the axis, they are created once and shared between all pages.
Due to the limited resolution (66x87 dots on DIN A4 with a vertical margin of one cell) multiple data points may be placed at the same dot position. This behavior can not be mitigated, and might distort the perception of the data distribution.
## Axis
The tick marks on the axis are placed at constant intervals, currently 3 Braille cells.
The axis reuse the calculated ratios described in [Token placing](#token-placing) for the estimation of values at the tick marks:
``` java
final int xAxisTickCount = xDots / xAxisStepWidth + 1; // The number of tick marks on the x axis
for (int x = 0; x < xAxisTickCount; x++) {
int tickPos = x * xAxisStepWidth; // The position of the tick mark in dots
double val = xMin + tickPos / xRatio; // The value at the position of the tick mark
...
}
```
For labels at the tick marks, a gap of one cell is introduced to ensure readability of the labels.
Because of the limited space, I decided to move the actual values at the tick marks to the legend. The tick marks themselves are labeled with the characters `a` to `z`. In the legend, these labels are mapped to the actual values for bot the x and y axis separately.
## Title
The title is generated separately for each document by concatenating the argument of the `title` command line parameter with a separator sign and the name of the current data set: `${title}-${data_set_name}`.
## Legend
![scatterplot_example_legend](img/ScatterPlot_example_legend.svg)
## References
[1] Engel, C: Kriterien zur Erstellung taktiler Diagramme und Diagrammbeschreibungen. Technische Universität Dresden, Professur Mensch-Computer Interaktion.
\ No newline at end of file