1 // Copyright 2015-2018 Hans Dembinski
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //[ guide_histogram_streaming
9 #include <boost/histogram.hpp>
10 #include <boost/histogram/ostream.hpp>
17 using namespace boost::histogram;
19 std::ostringstream os;
21 auto h1 = make_histogram(axis::regular<>(5, -1.0, 1.0, "axis 1"));
27 // 1D histograms are rendered as an ASCII drawing
30 auto h2 = make_histogram(axis::regular<>(2, -1.0, 1.0, "axis 1"),
31 axis::category<std::string>({"red", "blue"}, "axis 2"));
33 // higher dimensional histograms just have their cell counts listed
36 std::cout << os.str() << std::endl;
40 "histogram(regular(5, -1, 1, metadata=\"axis 1\", options=underflow | overflow))\n"
41 " +-------------------------------------------------------------+\n"
43 "[ -1, -0.6) 2 |============================== |\n"
44 "[-0.6, -0.2) 4 |============================================================ |\n"
45 "[-0.2, 0.2) 3 |============================================= |\n"
47 "[ 0.6, 1) 1 |=============== |\n"
49 " +-------------------------------------------------------------+\n"
51 " regular(2, -1, 1, metadata=\"axis 1\", options=underflow | overflow)\n"
52 " category(\"red\", \"blue\", metadata=\"axis 2\", options=overflow)\n"
53 " (-1 0): 0 ( 0 0): 0 ( 1 0): 0 ( 2 0): 0 (-1 1): 0 ( 0 1): 0\n"
54 " ( 1 1): 0 ( 2 1): 0 (-1 2): 0 ( 0 2): 0 ( 1 2): 0 ( 2 2): 0\n"