- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
- CMake 3.14 or higher (optional, for building examples/tests)
CppPlot is a header-only library. Just copy the include/cppplot folder to your project and include it:
#include "cppplot/cppplot.hpp"Compile with C++17:
# Windows (MinGW)
g++ -std=c++17 -I/path/to/cppplot/include your_file.cpp -o your_program
# Linux/Mac
g++ -std=c++17 -I/path/to/cppplot/include your_file.cpp -o your_program -lmAdd CppPlot to your project:
add_subdirectory(cppplot)
target_link_libraries(your_target PRIVATE cppplot)include(FetchContent)
FetchContent_Declare(
cppplot
GIT_REPOSITORY https://github.com/yourusername/cppplot.git
GIT_TAG main
)
FetchContent_MakeAvailable(cppplot)
target_link_libraries(your_target PRIVATE cppplot)# Create build directory
mkdir build
cd build
# Configure
cmake ..
# Build
cmake --build .
# Run tests
ctest
# Run examples
./examples/basic_plot
./examples/subplots
./examples/scientificg++ -std=c++17 -D_USE_MATH_DEFINES -Iinclude examples/quick_start.cpp -o quick_start.execl /std:c++17 /EHsc /Iinclude examples/quick_start.cpp- Create new C++ project
- Add
includefolder to Include Directories - Set C++ Language Standard to C++17
- Add source files and build
Add before including cppplot:
#define _USE_MATH_DEFINES
#include <cmath>Or use CMake definition:
target_compile_definitions(your_target PRIVATE _USE_MATH_DEFINES)Make sure to link math library:
g++ -std=c++17 -Iinclude your_file.cpp -o your_program -lmEnsure your terminal supports UTF-8 or use ASCII-only labels.