version 0.4.1
matplothelper.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
10#pragma once
11#include <matplot/matplot.h>
12
13#include <Eigen/Core>
14namespace Ikarus::plot {
23void draw_xy(const Eigen::VectorXd& x, const Eigen::VectorXd& y);
24
35template <typename FunctionType>
36void drawFunction(FunctionType&& f, std::pair<double, double>&& xRange, int eValuationPoints = 100) {
37 std::vector<double> x = matplot::linspace(xRange.first, xRange.second, eValuationPoints);
38 std::vector<double> y = matplot::transform(x, [&f](auto xL) { return f(xL); });
39 matplot::plot(x, y, "-o");
40 matplot::hold(matplot::on);
41}
42
43} // namespace Ikarus::plot
Definition: matplothelper.hh:14
void draw_xy(const Eigen::VectorXd &x, const Eigen::VectorXd &y)
Draw a 2D plot with given x and y vectors.
void drawFunction(FunctionType &&f, std::pair< double, double > &&xRange, int eValuationPoints=100)
Draw the plot of a mathematical function.
Definition: matplothelper.hh:36