Skip to content

Plotting (uses matplotlib)

plot_save function

template <typename T>
void plot_save(const std::string &name, const T &x,
               const std::string &options = "")

Plot data using python and save to file

Source code
template <typename T>
void plot_save(const std::string& name, const T& x, const std::string& options = "")
{
    plot_show(name, x, concat_args(options, "file='../svg/" + name + ".svg'"));
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/python_plot.hpp#L140

plot_show function

template <typename T>
void plot_show(const std::string &name, const T &x,
               const std::string &options = "")

Plot data using python

Source code
template <typename T>
void plot_show(const std::string& name, const T& x, const std::string& options = "")
{
    print(name, "...");
    auto array = make_array_ref(x);
    std::string ss;
    ss += python_prologue() + "data = [\n";
    for (size_t i = 0; i < array.size(); i++)
        ss += as_string(cometa::fmt<'g', 20, 17>(internal_generic::flush_to_zero(array[i])), ",\n");
    ss += "]\n";

    ss += "dspplot.plot(" + concat_args("data", options) + ")\n";

    internal_generic::python(name, ss);
    print("done\n");
}

https://github.com/kfrlib/kfr/blob//include/kfr/io/python_plot.hpp#L122


Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/