|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "<img src=\"xeus-cling.svg\">" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "code", |
| 12 | + "execution_count": null, |
| 13 | + "metadata": {}, |
| 14 | + "outputs": [], |
| 15 | + "source": [ |
| 16 | + "#include <vector>\n", |
| 17 | + "#include <string>\n", |
| 18 | + "\n", |
| 19 | + "#include \"xtensor/xtensor.hpp\"\n", |
| 20 | + "#include \"xtensor/xrandom.hpp\"\n", |
| 21 | + "#include \"xtensor/xeval.hpp\"\n", |
| 22 | + "#include \"xtensor/xmath.hpp\"\n", |
| 23 | + "\n", |
| 24 | + "#include \"xwidgets/xslider.hpp\"\n", |
| 25 | + "#include \"xwidgets/xlink.hpp\"\n", |
| 26 | + "\n", |
| 27 | + "#include \"xplot/xfigure.hpp\"\n", |
| 28 | + "#include \"xplot/xmarks.hpp\"\n", |
| 29 | + "#include \"xplot/xaxes.hpp\"" |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "code", |
| 34 | + "execution_count": null, |
| 35 | + "metadata": {}, |
| 36 | + "outputs": [], |
| 37 | + "source": [ |
| 38 | + "std::size_t n = 200;\n", |
| 39 | + "\n", |
| 40 | + "auto x = xt::linspace(0.0, 10.0, n);\n", |
| 41 | + "\n", |
| 42 | + "xt::random::seed(0);\n", |
| 43 | + "auto cumsum = xt::eval(xt::cumsum(xt::random::randn<double>({n})));\n", |
| 44 | + "auto y = xt::eval(xt::floor(cumsum * 10.0));\n", |
| 45 | + "\n", |
| 46 | + "auto fig = xpl::figure().title(\"Histogram\").finalize();\n", |
| 47 | + "\n", |
| 48 | + "xpl::linear_scale xs, ys;\n", |
| 49 | + "xpl::hist hist(xs, ys);\n", |
| 50 | + "hist.sample = y;\n", |
| 51 | + "hist.bins = 25;\n", |
| 52 | + "hist.colors = std::vector<std::string>({\"#1f77b4\"});\n", |
| 53 | + "\n", |
| 54 | + "xpl::axis hx(xs), hy(ys);\n", |
| 55 | + "hy.orientation = \"vertical\";\n", |
| 56 | + "fig.add_axis(hx);\n", |
| 57 | + "fig.add_axis(hy);\n", |
| 58 | + "\n", |
| 59 | + "fig.add_mark(hist);\n", |
| 60 | + "fig" |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + "cell_type": "code", |
| 65 | + "execution_count": null, |
| 66 | + "metadata": {}, |
| 67 | + "outputs": [], |
| 68 | + "source": [ |
| 69 | + "auto slider = xw::slider<std::size_t>()\n", |
| 70 | + " .min(1).max(100)\n", |
| 71 | + " .value(30).finalize();\n", |
| 72 | + "auto l = xw::link(slider, \"value\", hist, \"bins\");\n", |
| 73 | + "slider" |
| 74 | + ] |
| 75 | + } |
| 76 | + ], |
| 77 | + "metadata": { |
| 78 | + "kernelspec": { |
| 79 | + "display_name": "C++14", |
| 80 | + "language": "C++14", |
| 81 | + "name": "xcpp14" |
| 82 | + }, |
| 83 | + "language_info": { |
| 84 | + "codemirror_mode": "text/x-c++src", |
| 85 | + "file_extension": ".cpp", |
| 86 | + "mimetype": "text/x-c++src", |
| 87 | + "name": "c++", |
| 88 | + "version": "14" |
| 89 | + } |
| 90 | + }, |
| 91 | + "nbformat": 4, |
| 92 | + "nbformat_minor": 4 |
| 93 | +} |
0 commit comments