- int y = 103 + (rabund.getNumBins()*5);
- if (maxbin != 0) {
- //convert maxbin to relative abundance again
- if (scaler == "log10") {
- maxbin = pow(10, maxbin) / 100;
- }else if (scaler == "log2") {
- maxbin = pow(2, maxbin) / 100;
- }else { maxbin = pow(10, maxbin) / 100; }
- }else { maxbin = 0.00; }
-
- //5 is the number of boxes in the legend
- float maxbinScaler = maxbin / 10;
- float colorScaler = 255 / 10;
-
- for (int i = 0; i < 10; i++) {
- string label = toString(((i+1) * maxbinScaler));
- //set precision of relative abundance to 3
- int pos = label.find_first_of('.');
- label = label.substr(0,pos+4);
- color = toHex(int((float)(i+1) * colorScaler));
-
- outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"30\" height=\"10\"/>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\">" + label + "</text>\n";
- x += 30;
- }
-
- x = 0;