MCPcopy Create free account
hub / github.com/BirolLab/abyss / barplot

Method barplot

Common/Histogram.cpp:69–95  ·  view source on GitHub ↗

Return a unicode bar plot. * @param n number of buckets */

Source from the content-addressed store, hash-verified

67 * @param n number of buckets
68 */
69string Histogram::barplot(unsigned nbins) const
70{
71 /** Unicode bar characters. */
72 static const char* bars[10] = {
73 " ", "_",
74 "\342\226\201", // 9601
75 "\342\226\202", // 9602
76 "\342\226\203", // 9603
77 "\342\226\204", // 9604
78 "\342\226\205", // 9605
79 "\342\226\206", // 9606
80 "\342\226\207", // 9607
81 "\342\226\210", // 9608
82 };
83
84 Histogram::Bins bins = bin(nbins);
85 ostringstream ss;
86 Histogram::Bins::value_type max
87 = 1 + *max_element(bins.begin(), bins.end());
88 for (Histogram::Bins::const_iterator it = bins.begin();
89 it != bins.end(); ++it)
90 ss << bars[10 * *it / max];
91 string s(ss.str());
92 while (!s.empty() && *s.rbegin() == ' ')
93 s.erase(s.size() - 1);
94 return s;
95}
96
97/** Return a unicode bar plot. */
98string Histogram::barplot() const

Callers 4

GraphUtil.hFile · 0.80
mainFunction · 0.80
mainFunction · 0.80
printHistogramStatsFunction · 0.80

Calls 6

eraseMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected