Skip to content

Commit

Permalink
Enable cmake include definition
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneken authored and lava committed Apr 22, 2021
1 parent 3dda526 commit ef0383f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmake/matplotlib_cppConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ if(NOT TARGET matplotlib_cpp::matplotlib_cpp)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(Python3 COMPONENTS NumPy)
include("${matplotlib_cpp_CMAKE_DIR}/matplotlib_cppTargets.cmake")

get_target_property(matplotlib_cpp_INCLUDE_DIRS matplotlib_cpp::matplotlib_cpp INTERFACE_INCLUDE_DIRECTORIES)

endif()

1 comment on commit ef0383f

@hassanain34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <matplotlibcpp.h>
#include
#include

namespace plt = matplotlibcpp;

int main() {
// Generate x values
std::vector x, sin_y, cos_y;
int points = 1000;
for (int i = 0; i < points; ++i) {
double t = i * 0.01;
x.push_back(t);
sin_y.push_back(std::sin(t));
cos_y.push_back(std::cos(t));
}

// Plot sine and cosine on the same graph
plt::plot(x, sin_y, "r-", {{"label", "sin(x)"}});  // Red solid line for sin(x)
plt::plot(x, cos_y, "b--", {{"label", "cos(x)"}});  // Blue dashed line for cos(x)

// Set labels and title
plt::xlabel("x");
plt::ylabel("y");
plt::title("Sine and Cosine Waves");

// Show legend
plt::legend();

// Display the plot
plt::show();

return 0;

}

Please sign in to comment.