Skip to content

Commit cb8f135

Browse files
committed
add default template type to semilog plots
1 parent 954b3e5 commit cb8f135

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

matplotlibcpp.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,7 @@ template <typename Vector> PyObject *get_array(const Vector &v) {
392392
return varray;
393393
}
394394

395-
// TODO maybe we have to add a function for Eigen matrices, not sure
396-
// if the v[0] is valid for matrices and also the ::std::vector &v_row
397-
// probably doesn't work
395+
// specialized get_2darray function for nested std::vectors
398396
template <typename Numeric>
399397
PyObject *get_2darray(const std::vector<::std::vector<Numeric>> &v) {
400398
detail::_interpreter::get(); // interpreter needs to be initialized for the
@@ -420,7 +418,7 @@ PyObject *get_2darray(const std::vector<::std::vector<Numeric>> &v) {
420418
return reinterpret_cast<PyObject *>(varray);
421419
}
422420

423-
// suitable for Eigen matrices
421+
// suitable for more general matrices (especially Eigen matrices)
424422
template <typename Matrix>
425423
PyObject *get_2darray(const Matrix &A) {
426424
detail::_interpreter::get(); // interpreter needs to be initialized for the
@@ -583,7 +581,7 @@ bool semilogx(const VectorX &x, const VectorY &y,
583581
return semilogx(x, y, "", keywords);
584582
}
585583

586-
template <typename VectorY>
584+
template <typename VectorY = std::vector<double>>
587585
bool semilogx(const VectorY &y, const std::string &s = "",
588586
const std::map<std::string, std::string> &keywords = {}) {
589587
std::vector<std::size_t> x(y.size());
@@ -593,7 +591,7 @@ bool semilogx(const VectorY &y, const std::string &s = "",
593591
return semilogx(x, y, s, keywords);
594592
}
595593

596-
template <typename VectorY>
594+
template <typename VectorY = std::vector<double>>
597595
bool semilogx(const VectorY &y,
598596
const std::map<std::string, std::string> &keywords) {
599597
std::vector<std::size_t> x(y.size());
@@ -617,7 +615,7 @@ bool semilogy(const VectorX &x, const VectorY &y,
617615
return semilogy(x, y, "", keywords);
618616
}
619617

620-
template <typename VectorY>
618+
template <typename VectorY = std::vector<double>>
621619
bool semilogy(const VectorY &y, const std::string &s = "",
622620
const std::map<std::string, std::string> &keywords = {}) {
623621
std::vector<std::size_t> x(y.size());
@@ -627,7 +625,7 @@ bool semilogy(const VectorY &y, const std::string &s = "",
627625
return semilogy(x, y, s, keywords);
628626
}
629627

630-
template <typename VectorY>
628+
template <typename VectorY = std::vector<double>>
631629
bool semilogy(const VectorY &y,
632630
const std::map<std::string, std::string> &keywords) {
633631
std::vector<std::size_t> x(y.size());

0 commit comments

Comments
 (0)