Austin Schuh | ab802d5 | 2020-07-03 18:11:11 -0700 | [diff] [blame] | 1 | #include "../matplotlibcpp.h" |
| 2 | |
| 3 | #include <cmath> |
| 4 | |
| 5 | namespace plt = matplotlibcpp; |
| 6 | |
| 7 | int main() |
| 8 | { |
| 9 | std::vector<double> x, y, z; |
| 10 | double theta, r; |
| 11 | double z_inc = 4.0/99.0; double theta_inc = (8.0 * M_PI)/99.0; |
| 12 | |
| 13 | for (double i = 0; i < 100; i += 1) { |
| 14 | theta = -4.0 * M_PI + theta_inc*i; |
| 15 | z.push_back(-2.0 + z_inc*i); |
| 16 | r = z[i]*z[i] + 1; |
| 17 | x.push_back(r * sin(theta)); |
| 18 | y.push_back(r * cos(theta)); |
| 19 | } |
| 20 | |
| 21 | std::map<std::string, std::string> keywords; |
| 22 | keywords.insert(std::pair<std::string, std::string>("label", "parametric curve") ); |
| 23 | |
| 24 | plt::plot3(x, y, z, keywords); |
| 25 | plt::xlabel("x label"); |
| 26 | plt::ylabel("y label"); |
| 27 | plt::set_zlabel("z label"); // set_zlabel rather than just zlabel, in accordance with the Axes3D method |
| 28 | plt::legend(); |
| 29 | plt::show(); |
| 30 | } |