diff --git a/CMakeLists.txt b/CMakeLists.txt index bb2decd8..15e80902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,131 +3,97 @@ project(matplotlib_cpp LANGUAGES CXX) include(GNUInstallDirs) set(PACKAGE_NAME matplotlib_cpp) -set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${PACKAGE_NAME}/cmake) - +set(USING_PYTHON3 True) +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") +set(INSTALL_INCLUDE_DIR include CACHE PATH + "Installation directory for header files") + +foreach(p LIB BIN INCLUDE CMAKE) + set(var INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() +endforeach() # Library target add_library(matplotlib_cpp INTERFACE) target_include_directories(matplotlib_cpp INTERFACE - $ + $ $ ) -target_compile_features(matplotlib_cpp INTERFACE - cxx_std_11 -) +target_compile_features(matplotlib_cpp INTERFACE cxx_std_17) + # TODO: Use `Development.Embed` component when requiring cmake >= 3.18 -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) -target_link_libraries(matplotlib_cpp INTERFACE - Python3::Python - Python3::Module -) -find_package(Python3 COMPONENTS NumPy) -if(Python3_NumPy_FOUND) +if(USING_PYTHON3) + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) target_link_libraries(matplotlib_cpp INTERFACE - Python3::NumPy + Python3::Python + Python3::Module ) + find_package(Python3 COMPONENTS NumPy) + if(Python3_NumPy_FOUND) + target_link_libraries(matplotlib_cpp INTERFACE + Python3::NumPy + ) + else() + target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY) + endif() else() - target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY) -endif() -install( - TARGETS matplotlib_cpp - EXPORT install_targets -) - - -# Examples -add_executable(minimal examples/minimal.cpp) -target_link_libraries(minimal PRIVATE matplotlib_cpp) -set_target_properties(minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(basic examples/basic.cpp) -target_link_libraries(basic PRIVATE matplotlib_cpp) -set_target_properties(basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(modern examples/modern.cpp) -target_link_libraries(modern PRIVATE matplotlib_cpp) -set_target_properties(modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(animation examples/animation.cpp) -target_link_libraries(animation PRIVATE matplotlib_cpp) -set_target_properties(animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(nonblock examples/nonblock.cpp) -target_link_libraries(nonblock PRIVATE matplotlib_cpp) -set_target_properties(nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(xkcd examples/xkcd.cpp) -target_link_libraries(xkcd PRIVATE matplotlib_cpp) -set_target_properties(xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(bar examples/bar.cpp) -target_link_libraries(bar PRIVATE matplotlib_cpp) -set_target_properties(bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(fill_inbetween examples/fill_inbetween.cpp) -target_link_libraries(fill_inbetween PRIVATE matplotlib_cpp) -set_target_properties(fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(fill examples/fill.cpp) -target_link_libraries(fill PRIVATE matplotlib_cpp) -set_target_properties(fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(update examples/update.cpp) -target_link_libraries(update PRIVATE matplotlib_cpp) -set_target_properties(update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(subplot2grid examples/subplot2grid.cpp) -target_link_libraries(subplot2grid PRIVATE matplotlib_cpp) -set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -add_executable(lines3d examples/lines3d.cpp) -target_link_libraries(lines3d PRIVATE matplotlib_cpp) -set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -if(Python3_NumPy_FOUND) - add_executable(surface examples/surface.cpp) - target_link_libraries(surface PRIVATE matplotlib_cpp) - set_target_properties(surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - - add_executable(colorbar examples/colorbar.cpp) - target_link_libraries(colorbar PRIVATE matplotlib_cpp) - set_target_properties(colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - add_executable(contour examples/contour.cpp) - target_link_libraries(contour PRIVATE matplotlib_cpp) - set_target_properties(contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - - add_executable(spy examples/spy.cpp) - target_link_libraries(spy PRIVATE matplotlib_cpp) - set_target_properties(spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + find_package(Python2 COMPONENTS Interpreter Development REQUIRED) + target_link_libraries(matplotlib_cpp INTERFACE + Python2::Python + Python2::Module + ) + find_package(Python2 COMPONENTS NumPy) + if(Python2_NumPy_FOUND) + target_link_libraries(matplotlib_cpp INTERFACE + Python2::NumPy + ) + else() + target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY) + endif() endif() -# Install headers -install(FILES - "${PROJECT_SOURCE_DIR}/matplotlibcpp.h" - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(TARGETS matplotlib_cpp + EXPORT matplotlib_cpp-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/matplotlib_cpp" +) # Install targets file -install(EXPORT install_targets - FILE - ${PACKAGE_NAME}Targets.cmake - NAMESPACE - ${PACKAGE_NAME}:: - DESTINATION - ${INSTALL_CONFIGDIR} +install(EXPORT matplotlib_cpp-targets + FILE ${PACKAGE_NAME}Targets.cmake + DESTINATION ${INSTALL_CMAKE_DIR}/cmake/matplotlib_cpp ) - # Install matplotlib_cppConfig.cmake include(CMakePackageConfigHelpers) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PACKAGE_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake - INSTALL_DESTINATION ${INSTALL_CONFIGDIR} + INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}/cmake/matplotlib_cpp ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake - DESTINATION ${INSTALL_CONFIGDIR} + DESTINATION ${INSTALL_CMAKE_DIR}/cmake/matplotlib_cpp ) + +export(TARGETS matplotlib_cpp + FILE ${PACKAGE_NAME}Config.cmake) + +# Install headers +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/matplotlibcpp.h" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + + + +set(CMAKE_EXPORT_PACKAGE_REGISTRY ON) +export(PACKAGE matplotlib_cpp) diff --git a/cmake/matplotlib_cppConfig.cmake.in b/cmake/matplotlib_cppConfig.cmake.in index 86d25d09..6158a1d3 100644 --- a/cmake/matplotlib_cppConfig.cmake.in +++ b/cmake/matplotlib_cppConfig.cmake.in @@ -5,6 +5,6 @@ if(NOT TARGET matplotlib_cpp::matplotlib_cpp) 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) + get_target_property(matplotlib_cpp_INCLUDE_DIRS matplotlib_cpp INTERFACE_INCLUDE_DIRECTORIES) endif() diff --git a/contrib/Dockerfile b/contrib/Dockerfile deleted file mode 100644 index 850466fb..00000000 --- a/contrib/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM debian:10 AS builder -RUN apt-get update \ - && apt-get install --yes --no-install-recommends \ - g++ \ - libpython3-dev \ - make \ - python3 \ - python3-dev \ - python3-numpy - -ADD Makefile matplotlibcpp.h numpy_flags.py /opt/ -ADD examples/*.cpp /opt/examples/ -RUN cd /opt \ - && make PYTHON_BIN=python3 \ - && ls examples/build - -FROM debian:10 -RUN apt-get update \ - && apt-get install --yes --no-install-recommends \ - libpython3-dev \ - python3-matplotlib \ - python3-numpy - -COPY --from=builder /opt/examples/build /opt/ -RUN cd /opt \ - && ls \ - && ./basic diff --git a/contrib/Makefile b/contrib/Makefile deleted file mode 100644 index f659cd94..00000000 --- a/contrib/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: docker_build - -docker_build: - cd .. && \ - docker build . -f contrib/Dockerfile -t matplotlibcpp && \ - cd contrib diff --git a/contrib/README.md b/contrib/README.md deleted file mode 100644 index 0af8515c..00000000 --- a/contrib/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# contrib/ - -This folder contains contributions that may be useful to users of this library, but -have a too specialized audience to become part of the main tree. - -In particular, things in here will have a higher rate of bit-rot, since -contributors are not required to and may be unable to check whether their -changes break any of them. - -## Windows support -Tested on the following environment -* Windows 10 - 64bit -* Anaconda 4.3 (64 bit) -* Python 3.6.0 -* CMake 3.9.4 -* Visual Studio 2017, 2015, 2013 - -### Configuring and Building Samples -1. Edit WinBuild.cmd for your environment(Line:5-7) - if NOT DEFINED MSVC_VERSION set MSVC_VERSION=[Your Visual Studio Version(12, 14, 15)] - if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release - if NOT DEFINED PYTHONHOME set PYTHONHOME=[Your Python Path] - -2. Run WinBuild.cmd to build -```cmd -> cd contrib -> WinBuild.cmd -``` -The `WinBuild.cmd` will set up temporal ENV variables and build binaries in (matplotlib root)/examples with the Release configuration. - -3. Find exe files in examples/build/Release -Note: platforms folder is necessary to make qt works. diff --git a/contrib/WinBuild.cmd b/contrib/WinBuild.cmd deleted file mode 100644 index 9dfd627d..00000000 --- a/contrib/WinBuild.cmd +++ /dev/null @@ -1,61 +0,0 @@ -@echo off -@setlocal EnableDelayedExpansion - -REM ------Set Your Environment------------------------------- -if NOT DEFINED MSVC_VERSION set MSVC_VERSION=15 -if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release -if NOT DEFINED PYTHONHOME set PYTHONHOME=C:/Users/%username%/Anaconda3 -REM --------------------------------------------------------- - -set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7" -set VALUE_NAME=15.0 - -if "%MSVC_VERSION%"=="14" ( - if "%processor_architecture%" == "AMD64" ( - set CMAKE_GENERATOR=Visual Studio 14 2015 Win64 - ) else ( - set CMAKE_GENERATOR=Visual Studio 14 2015 - ) -) else if "%MSVC_VERSION%"=="12" ( - if "%processor_architecture%" == "AMD64" ( - set CMAKE_GENERATOR=Visual Studio 12 2013 Win64 - ) else ( - set CMAKE_GENERATOR=Visual Studio 12 2013 - ) -) else if "%MSVC_VERSION%"=="15" ( - if "%processor_architecture%" == "AMD64" ( - set CMAKE_GENERATOR=Visual Studio 15 2017 Win64 - ) else ( - set CMAKE_GENERATOR=Visual Studio 15 2017 - ) -) -if "%MSVC_VERSION%"=="15" ( - for /F "usebackq tokens=1,2,*" %%A in (`REG QUERY %KEY_NAME% /v %VALUE_NAME%`) do ( - set batch_file=%%CVC\Auxiliary\Build\vcvarsall.bat - ) -) else ( - set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat -) -call "%batch_file%" %processor_architecture% - -pushd .. -pushd examples -if NOT EXIST build mkdir build -pushd build - -cmake -G"!CMAKE_GENERATOR!" ^ - -DPYTHONHOME:STRING=%PYTHONHOME%^ - -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^ - %~dp0 -cmake --build . --config %CMAKE_CONFIG% - -pushd %CMAKE_CONFIG% -if not EXIST platforms mkdir platforms -if EXIST %PYTHONHOME%/Library/plugins/platforms/qwindows.dll ^ -cp %PYTHONHOME%/Library/plugins/platforms/qwindows.dll ./platforms/ -popd -REM move ./%CMAKE_CONFIG% ../ -popd -popd -popd -@endlocal diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index 3da8ad62..00000000 --- a/examples/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -animation -bar -basic -fill -fill_inbetween -imshow -minimal -modern -nonblock -quiver -subplot -surface -update -xkcd diff --git a/examples/animation.cpp b/examples/animation.cpp deleted file mode 100644 index d9794300..00000000 --- a/examples/animation.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include "../matplotlibcpp.h" - -namespace plt = matplotlibcpp; - -int main() -{ - int n = 1000; - std::vector x, y, z; - - for(int i=0; i -#include -#include "../matplotlibcpp.h" -namespace plt = matplotlibcpp; - -int main(int argc, char **argv) { - std::vector test_data; - for (int i = 0; i < 20; i++) { - test_data.push_back(i); - } - - plt::bar(test_data); - plt::show(); - - return (0); -} diff --git a/examples/bar.png b/examples/bar.png deleted file mode 100644 index be6af0fa..00000000 Binary files a/examples/bar.png and /dev/null differ diff --git a/examples/basic.cpp b/examples/basic.cpp deleted file mode 100644 index 2dc34c74..00000000 --- a/examples/basic.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include -#include "../matplotlibcpp.h" - -namespace plt = matplotlibcpp; - -int main() -{ - // Prepare data. - int n = 5000; - std::vector x(n), y(n), z(n), w(n,2); - for(int i=0; i -#include -#include "../matplotlibcpp.h" - -using namespace std; -namespace plt = matplotlibcpp; - -int main() -{ - // Prepare data - int ncols = 500, nrows = 300; - std::vector z(ncols * nrows); - for (int j=0; j - -namespace plt = matplotlibcpp; - -int main() -{ - std::vector> x, y, z; - for (double i = -5; i <= 5; i += 0.25) { - std::vector x_row, y_row, z_row; - for (double j = -5; j <= 5; j += 0.25) { - x_row.push_back(i); - y_row.push_back(j); - z_row.push_back(::std::sin(::std::hypot(i, j))); - } - x.push_back(x_row); - y.push_back(y_row); - z.push_back(z_row); - } - - plt::contour(x, y, z); - plt::show(); -} diff --git a/examples/fill.cpp b/examples/fill.cpp deleted file mode 100644 index 6059b475..00000000 --- a/examples/fill.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#define _USE_MATH_DEFINES -#include "../matplotlibcpp.h" -#include - -using namespace std; -namespace plt = matplotlibcpp; - -// Example fill plot taken from: -// https://matplotlib.org/gallery/misc/fill_spiral.html -int main() { - // Prepare data. - vector theta; - for (double d = 0; d < 8 * M_PI; d += 0.1) - theta.push_back(d); - - const int a = 1; - const double b = 0.2; - - for (double dt = 0; dt < 2 * M_PI; dt += M_PI/2.0) { - vector x1, y1, x2, y2; - for (double th : theta) { - x1.push_back( a*cos(th + dt) * exp(b*th) ); - y1.push_back( a*sin(th + dt) * exp(b*th) ); - - x2.push_back( a*cos(th + dt + M_PI/4.0) * exp(b*th) ); - y2.push_back( a*sin(th + dt + M_PI/4.0) * exp(b*th) ); - } - - x1.insert(x1.end(), x2.rbegin(), x2.rend()); - y1.insert(y1.end(), y2.rbegin(), y2.rend()); - - plt::fill(x1, y1, {}); - } - plt::show(); -} diff --git a/examples/fill.png b/examples/fill.png deleted file mode 100644 index aa1fc0db..00000000 Binary files a/examples/fill.png and /dev/null differ diff --git a/examples/fill_between.png b/examples/fill_between.png deleted file mode 100644 index a199423b..00000000 Binary files a/examples/fill_between.png and /dev/null differ diff --git a/examples/fill_inbetween.cpp b/examples/fill_inbetween.cpp deleted file mode 100644 index 788d0086..00000000 --- a/examples/fill_inbetween.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#define _USE_MATH_DEFINES -#include "../matplotlibcpp.h" -#include -#include - -using namespace std; -namespace plt = matplotlibcpp; - -int main() { - // Prepare data. - int n = 5000; - std::vector x(n), y(n), z(n), w(n, 2); - for (int i = 0; i < n; ++i) { - x.at(i) = i * i; - y.at(i) = sin(2 * M_PI * i / 360.0); - z.at(i) = log(i); - } - - // Prepare keywords to pass to PolyCollection. See - // https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.fill_between.html - std::map keywords; - keywords["alpha"] = "0.4"; - keywords["color"] = "grey"; - keywords["hatch"] = "-"; - - plt::fill_between(x, y, z, keywords); - plt::show(); -} diff --git a/examples/imshow.cpp b/examples/imshow.cpp deleted file mode 100644 index b11661e4..00000000 --- a/examples/imshow.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include -#include "../matplotlibcpp.h" - -using namespace std; -namespace plt = matplotlibcpp; - -int main() -{ - // Prepare data - int ncols = 500, nrows = 300; - std::vector z(ncols * nrows); - for (int j=0; j - -namespace plt = matplotlibcpp; - -int main() -{ - std::vector 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 keywords; - keywords.insert(std::pair("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(); -} diff --git a/examples/lines3d.png b/examples/lines3d.png deleted file mode 100644 index 7a0c478a..00000000 Binary files a/examples/lines3d.png and /dev/null differ diff --git a/examples/minimal.cpp b/examples/minimal.cpp deleted file mode 100644 index fbe1e1cd..00000000 --- a/examples/minimal.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "../matplotlibcpp.h" - -namespace plt = matplotlibcpp; - -int main() { - plt::plot({1,3,2,4}); - plt::show(); -} diff --git a/examples/minimal.png b/examples/minimal.png deleted file mode 100644 index 0f6cf373..00000000 Binary files a/examples/minimal.png and /dev/null differ diff --git a/examples/modern.cpp b/examples/modern.cpp deleted file mode 100644 index 871ef2b0..00000000 --- a/examples/modern.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include "../matplotlibcpp.h" - -using namespace std; -namespace plt = matplotlibcpp; - -int main() -{ - // plot(y) - the x-coordinates are implicitly set to [0,1,...,n) - //plt::plot({1,2,3,4}); - - // Prepare data for parametric plot. - int n = 5000; // number of data points - vector x(n),y(n); - for(int i=0; i -#include "../matplotlibcpp.h" - -namespace plt = matplotlibcpp; - - -using namespace matplotlibcpp; -using namespace std; - -int main() -{ - // Prepare data. - int n = 5000; - std::vector x(n), y(n), z(n), w(n,2); - for(int i=0; i x, y, u, v; - for (int i = -5; i <= 5; i++) { - for (int j = -5; j <= 5; j++) { - x.push_back(i); - u.push_back(-i); - y.push_back(j); - v.push_back(-j); - } - } - - plt::quiver(x, y, u, v); - plt::show(); -} \ No newline at end of file diff --git a/examples/quiver.png b/examples/quiver.png deleted file mode 100644 index 9d7be1ee..00000000 Binary files a/examples/quiver.png and /dev/null differ diff --git a/examples/spy.cpp b/examples/spy.cpp deleted file mode 100644 index 6027a487..00000000 --- a/examples/spy.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "../matplotlibcpp.h" - -#include -#include - -namespace plt = matplotlibcpp; - -int main() -{ - const int n = 20; - std::vector> matrix; - - for (int i = 0; i < n; ++i) { - std::vector row; - for (int j = 0; j < n; ++j) { - if (i == j) - row.push_back(-2); - else if (j == i - 1 || j == i + 1) - row.push_back(1); - else - row.push_back(0); - } - matrix.push_back(row); - } - - plt::spy(matrix, 5, {{"marker", "o"}}); - plt::show(); - - return 0; -} diff --git a/examples/subplot.cpp b/examples/subplot.cpp deleted file mode 100644 index bee322e0..00000000 --- a/examples/subplot.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include "../matplotlibcpp.h" - -using namespace std; -namespace plt = matplotlibcpp; - -int main() -{ - // Prepare data - int n = 500; - std::vector x(n), y(n), z(n), w(n,2); - for(int i=0; i -#include "../matplotlibcpp.h" - -using namespace std; -namespace plt = matplotlibcpp; - -int main() -{ - // Prepare data - int n = 500; - std::vector x(n), u(n), v(n), w(n); - for(int i=0; i - -namespace plt = matplotlibcpp; - -int main() -{ - std::vector> x, y, z; - for (double i = -5; i <= 5; i += 0.25) { - std::vector x_row, y_row, z_row; - for (double j = -5; j <= 5; j += 0.25) { - x_row.push_back(i); - y_row.push_back(j); - z_row.push_back(::std::sin(::std::hypot(i, j))); - } - x.push_back(x_row); - y.push_back(y_row); - z.push_back(z_row); - } - - plt::plot_surface(x, y, z); - plt::show(); -} diff --git a/examples/surface.png b/examples/surface.png deleted file mode 100644 index 6fc5fc76..00000000 Binary files a/examples/surface.png and /dev/null differ diff --git a/examples/update.cpp b/examples/update.cpp deleted file mode 100644 index 64f49067..00000000 --- a/examples/update.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#define _USE_MATH_DEFINES -#include -#include "../matplotlibcpp.h" -#include - -namespace plt = matplotlibcpp; - -void update_window(const double x, const double y, const double t, - std::vector &xt, std::vector &yt) -{ - const double target_length = 300; - const double half_win = (target_length/(2.*sqrt(1.+t*t))); - - xt[0] = x - half_win; - xt[1] = x + half_win; - yt[0] = y - half_win*t; - yt[1] = y + half_win*t; -} - - -int main() -{ - size_t n = 1000; - std::vector x, y; - - const double w = 0.05; - const double a = n/2; - - for (size_t i=0; i xt(2), yt(2); - - plt::title("Tangent of a sine curve"); - plt::xlim(x.front(), x.back()); - plt::ylim(-a, a); - plt::axis("equal"); - - // Plot sin once and for all. - plt::named_plot("sin", x, y); - - // Prepare plotting the tangent. - plt::Plot plot("tangent"); - - plt::legend(); - - for (size_t i=0; i -#include "../matplotlibcpp.h" -#include - -namespace plt = matplotlibcpp; - -int main() { - std::vector t(1000); - std::vector x(t.size()); - - for(size_t i = 0; i < t.size(); i++) { - t[i] = i / 100.0; - x[i] = sin(2.0 * M_PI * 1.0 * t[i]); - } - - plt::xkcd(); - plt::plot(t, x); - plt::title("AN ORDINARY SIN WAVE"); - plt::show(); -} - diff --git a/examples/xkcd.png b/examples/xkcd.png deleted file mode 100644 index c285e3d8..00000000 Binary files a/examples/xkcd.png and /dev/null differ diff --git a/matplotlibcpp.h b/include/matplotlibcpp.h similarity index 100% rename from matplotlibcpp.h rename to include/matplotlibcpp.h