|
|
@ -2,7 +2,6 @@
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
const size_t x=20;
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -35,7 +34,7 @@ void
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
const auto IMAGE_WIDTH = 400;
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
|
const auto IMAGE_HEIGHT = 300;
|
|
|
|
const auto TEXT_LEFT = IMAGE_WIDTH-30;
|
|
|
|
const auto TEXT_LEFT = 20;
|
|
|
|
const auto TEXT_BASELINE = 20;
|
|
|
|
const auto TEXT_BASELINE = 20;
|
|
|
|
const auto TEXT_WIDTH = 50;
|
|
|
|
const auto TEXT_WIDTH = 50;
|
|
|
|
const auto BIN_HEIGHT = 30;
|
|
|
|
const auto BIN_HEIGHT = 30;
|
|
|
@ -54,7 +53,7 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
const double bin_width = space * bin / max_count;
|
|
|
|
const double bin_width = space * bin / max_count;
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_rect(TEXT_LEFT - bin_width - 20, top, bin_width, BIN_HEIGHT, "black", "blue");
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "black", "blue");
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
svg_end();
|
|
|
|
svg_end();
|
|
|
@ -63,7 +62,7 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
for (size_t bin : bins) {
|
|
|
|
const double bin_width = BLOCK_WIDTH * bin;
|
|
|
|
const double bin_width = BLOCK_WIDTH * bin;
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
|
|
svg_rect(TEXT_LEFT - bin_width - 20, top, bin_width, BIN_HEIGHT, "black", "blue");
|
|
|
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "black", "blue");
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
top += BIN_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
svg_end();
|
|
|
|
svg_end();
|
|
|
|