matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

named_plot: template parameter Numeric

Open hriener opened this issue 4 years ago • 0 comments

I run into a minor problem using named_plot (https://github.com/lava/matplotlib-cpp/blob/master/matplotlibcpp.h#L1370): Is it intentional that the function has only one template parameter Numeric that is used for both vectors (X and Y)? In many cases I would prefer to use different types on the X- and Y-axis, e.g., uint32_t on the x-axis and double on the y-axis.

I replaced the lines 1370 and 1371

template<typename Numeric>
bool named_plot(const std::string& name, const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::string& format = "")

in my version by

template<typename NumericX, typename NumericY>
bool named_plot(const std::string& name, const std::vector<NumericX>& x, const std::vector<NumericY>& y, const std::string& format = "")

This change seems to resolve the issue.

hriener avatar Jan 28 '21 08:01 hriener