+void HeatMap::printLegend(int y, float maxbin) {
+ try {
+
+ //output legend and color labels
+ //go through map and give each score a color value
+ string color;
+ int x = 10;
+
+ //prints legend
+ for (int i = 1; i < 255; i++) {
+ color = toHex(int((float)(i)));
+ outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"1\" height=\"10\"/>\n";
+ x += 1;
+ }
+
+ //prints legend labels
+ x = 10;
+ for (int i = 1; i<=5; i++) {
+ float label;
+ if(scaler== "log10") { label = maxbin * log10(51*i) / log10(255); }
+ else if(scaler== "log2") { label = maxbin * log2(51*i) / log2(255); }
+ else if(scaler== "linear") { label = maxbin * 51 * i / 255; }
+ else { label = maxbin * log10(51*i) / log10(255); }
+ label = int(label * 1000 + 0.5);
+ label /= 1000.0;
+ string text = toString(label, 3);
+
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y-3) + "\">" + text + "</text>\n";
+ x += 60;
+ }
+ }
+
+ catch(exception& e) {
+ m->errorOut(e, "HeatMap", "printLegend");
+ exit(1);
+ }
+}