| 5 | #include <vector> |
| 6 | |
| 7 | int main() { |
| 8 | using namespace matplot; |
| 9 | |
| 10 | auto ax1 = subplot(2, 2, 0); |
| 11 | fplot("cos(x)"); |
| 12 | title("Subplot 1: Cosine"); |
| 13 | |
| 14 | auto ax2 = subplot(2, 2, 1); |
| 15 | fplot("1 - x**2/2 + x**4/24"); |
| 16 | title("Subplot 2: Polynomial"); |
| 17 | |
| 18 | auto ax3 = subplot(2, 2, {2, 3}); |
| 19 | fplot("cos(x)", "b"); |
| 20 | hold(on); |
| 21 | fplot("1 - x**2/2 + x**4/24", "g"); |
| 22 | title("Subplot 3 and 4: Both"); |
| 23 | |
| 24 | axis({ax1, ax2, ax3}, {-4, 4, inf, inf}); |
| 25 | |
| 26 | show(); |
| 27 | return 0; |
| 28 | } |