123456789101112131415161718192021222324252627282930 |
- #define _USE_MATH_DEFINES
- #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();
- }
|