Plotting graphs in C++

You could try https://github.com/lava/matplotlib-cpp, which looks like it is just a wrapper around matplotlib anyway, so you are still calling/using Python and matplotlib in the end. With this you probably can copy your code nearly verbatim to “C++”.

NameError from Python input() function

input reads and evaluates a Python expression. When it tries to evaluate it, it looks for a variable e, which is not defined, and fails. You almost always want to use raw_input instead. (And in Python3, input has this behaviour.) Or, better, on Unix, use readline so the user can edit their input.