blob: f3c201c520b5e79a0d90f3496e88ac5fe0ccc6d6 [file] [log] [blame]
#include "../matplotlibcpp.h"
#include <cmath>
namespace plt = matplotlibcpp;
int main()
{
std::vector<double> x, y, z;
double theta, r;
double z_inc = 4.0/99.0; double theta_inc = (8.0 * M_PI)/99.0;
for (double i = 0; i < 100; i += 1) {
theta = -4.0 * M_PI + theta_inc*i;
z.push_back(-2.0 + z_inc*i);
r = z[i]*z[i] + 1;
x.push_back(r * sin(theta));
y.push_back(r * cos(theta));
}
std::map<std::string, std::string> keywords;
keywords.insert(std::pair<std::string, std::string>("label", "parametric curve") );
plt::plot3(x, y, z, keywords);
plt::xlabel("x label");
plt::ylabel("y label");
plt::set_zlabel("z label"); // set_zlabel rather than just zlabel, in accordance with the Axes3D method
plt::legend();
plt::show();
}