8000 add keywords for spy, remove precision · lindanxia/matplotlib-cpp@208807d · GitHub
[go: up one dir, main page]

Skip to content

Commit 208807d

Browse files
committed
add keywords for spy, remove precision
1 parent ab37736 commit 208807d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

matplotlibcpp.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,19 @@ bool scatter(const VectorX &x, const VectorY &y, const double s = 1.0) {
900900

901901
// @brief Spy plot
902902
// @param A the matrix
903+
// @param precision Plot all elements above `|precision|`
904+
// @param keywords Additional keywords
903905
template <typename Matrix>
904-
bool spy(const Matrix &A, double precision=0) {
906+
bool spy(const Matrix &A,
907+
const std::map<std::string, std::string>& keywords = {}) {
905908
PyObject *Aarray = get_2darray(A);
906909

907910
PyObject *kwargs = PyDict_New();
908-
PyDict_SetItemString(kwargs, "precision", PyFloat_FromDouble(precision));
911+
for (std::map<std::string, std::string>::const_iterator it = keywords.begin();
912+
it != keywords.end(); ++it) {
913+
PyDict_SetItemString(kwargs, it->first.c_str(),
914+
PyUnicode_FromString(it->second.c_str()));
915+
}
909916

910917
PyObject *plot_args = PyTuple_New(1);
911918
PyTuple_SetItem(plot_args, 0, Aarray);

0 commit comments

Comments
 (0)
0