{"id":388,"library":"contourpy","title":"ContourPy: Contour Calculation for 2D Quadrilateral Grids","description":"ContourPy is a Python library for calculating contours of 2D quadrilateral grids, written in C++11 and wrapped using pybind11. It offers algorithms used in Matplotlib, including the 2005 and 2014 versions, as well as a newer algorithm with additional features available in both serial and multithreaded versions. The current version is 1.3.3, released on March 7, 2026, with a release cadence of approximately every 2-3 months.","status":"active","version":"1.3.3","language":"python","source_language":"en","source_url":"https://github.com/contourpy/contourpy","tags":["contour","2D grids","Python","C++11","pybind11","Matplotlib","multithreading"],"install":[{"cmd":"pip install contourpy","lang":"bash","label":"Install ContourPy"}],"dependencies":[{"reason":"Required for numerical operations","package":"numpy","optional":false}],"imports":[{"note":"Ensure correct import path to access contour generation functions","symbol":"contour_generator","correct":"from contourpy import contour_generator"}],"quickstart":{"code":"import numpy as np\nfrom contourpy import contour_generator\n\n# Create a 2x2 grid of z values\nz = np.array([[0.0, 0.1], [0.2, 0.3]])\n\n# Initialize the contour generator\ncont_gen = contour_generator(z=z)\n\n# Calculate contour lines at z-level 0.25\nlines = cont_gen.lines(0.25)\n\n# Calculate filled contours between z-levels 0.15 and 0.25\nfilled = cont_gen.filled(0.15, 0.25)\n\n# Visualize the contours using Matplotlib\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots()\nfor line in lines:\n    ax.plot(line[:, 0], line[:, 1], color='red')\nfor polygon in filled[0]:\n    ax.fill(polygon[:, 0], polygon[:, 1], color='gold', alpha=0.5)\nplt.show()","lang":"python","description":"A simple example demonstrating how to use ContourPy to generate and visualize contour lines and filled contours from a 2x2 grid of z values."},"warnings":[{"fix":"Upgrade to Python 3.11 or later.","message":"Support for Python versions below 3.11 has been dropped in version 1.3.3.","severity":"breaking","affected_versions":"1.3.3"},{"fix":"Use with caution or opt for the serial version for stability.","message":"The multithreaded option in the newer algorithm is considered experimental.","severity":"deprecated","affected_versions":"1.3.0"},{"fix":"Install the 'matplotlib' package using `pip install matplotlib` or ensure it is included in the project's dependency management.","message":"Missing required package: 'matplotlib'. The package 'matplotlib' was not found in the environment, preventing the script from running.","severity":"breaking","affected_versions":"1.3.3"},{"fix":"Install the matplotlib package using 'pip install matplotlib'.","message":"The 'matplotlib' package is not installed, leading to a ModuleNotFoundError.","severity":"breaking","affected_versions":"*"}],"env_vars":null,"search_vec":"'+11':23,81 '-3':74 '1.3.3':60 '2':73 '2005':36 '2014':38 '2026':65 '2d':5,17,77 '7':64 'addit':47 'algorithm':30,45 'approxim':71 'avail':49 'c':22,80 'cadenc':69 'calcul':3,14 'contour':2,15,76 'contourpi':1,8 'current':57 'everi':72 'featur':48 'grid':7,19,78 'includ':34 'librari':12 'march':63 'matplotlib':33,83 'month':75 'multithread':54,84 'newer':44 'offer':29 'pybind11':27,82 'python':11,79 'quadrilater':6,18 'releas':61,68 'serial':52 'use':26,31 'version':39,55,58 'well':41 'wrap':25 'written':20","created_at":"2026-03-28T11:14:29.093178+00:00","updated_at":"2026-04-16T03:44:11.517889+00:00","problems":[{"fix":"Ensure `contourpy` is installed using `pip install contourpy` or `conda install -c conda-forge contourpy`.","cause":"The `contourpy` package is not installed in the current Python environment or is not accessible via `sys.path`.","error":"ModuleNotFoundError: No module named 'contourpy'"},{"fix":"Install necessary build tools for your operating system (e.g., `build-essential` on Linux, Xcode on macOS, Visual C++ Build Tools on Windows) and then retry `pip install contourpy`. Alternatively, use `conda install -c conda-forge contourpy` to install pre-built binaries.","cause":"`pip` failed to compile the C++ extension of `contourpy` from source, often due to missing build tools (like a C++ compiler, `meson`, or `ninja`) or environment-specific issues.","error":"ERROR: Could not build wheels for contourpy, which is required to install pyproject.toml-based projects."},{"fix":"Check the Python version compatibility requirements for the desired `contourpy` version and upgrade your Python environment if needed. Try installing without a specific version constraint (`pip install contourpy`) to allow `pip` to find a compatible binary wheel, or manually select an older `contourpy` version known to be compatible with your Python.","cause":"The specified version of `contourpy` is not available for your current Python version or operating system, or there is a conflict with other installed packages requiring a different Python version.","error":"ERROR: Could not find a version that satisfies the requirement contourpy==X.Y.Z (from versions: ...)"},{"fix":"Downgrade NumPy to a version compatible with `contourpy` (typically `<2.0` if `contourpy` hasn't released a 2.x compatible version) or upgrade `contourpy` to a version that officially supports NumPy 2.0. Reinstalling `contourpy` and its dependencies after adjusting NumPy versions is recommended.","cause":"The `contourpy` library, or a dependency of it, was compiled against a different major version of NumPy than the one currently installed, leading to potential Application Binary Interface (ABI) incompatibility.","error":"A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0.dev0 as it may crash."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"1.3.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/contourpy/contourpy","docs":"https://contourpy.readthedocs.io","changelog":"https://contourpy.readthedocs.io/en/latest/changelog.html","pypi":"https://pypi.org/project/contourpy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}