Need help with matplotplusplus?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Global Rank
#36,704
Topics of expertise
scienti...
graphic...
scienti...
Conan
visuali...
Data vi...
data-sc...
cmake
Location
Ouro Preto
2.0K Stars 136 Forks MIT License 328 Commits 10 Opened issues

Description

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾

Services available

!
?

Need anything else?

Contributors list

# 36,704
C++
C
graphic...
scienti...
198 commits
# 362
C++
C
Electro...
Windows
22 commits
# 114,728
mac
c-plus-...
rpg
graphic...
21 commits
# 2,352
steam
laravel...
laravel...
advent-...
8 commits
# 212,302
Shell
fast-fo...
digital...
cpp17
3 commits
# 195,415
C++
cssinjs
js
scienti...
2 commits
# 272,337
C++
audioun...
Shell
TeX
2 commits
# 206,547
C++
scienti...
coreclr
c-sharp
2 commits
# 78,825
Shell
sed
spellch...
cpp11
1 commit
# 28,042
digital...
cpp17
cpluspl...
Raspber...
1 commit
# 463
C
c-plus-...
cpp-lib...
cmake-s...
1 commit

Matplot++

A C++ Graphics Library for Data Visualization

Matplot++


Data visualization can help programmers and scientists identify trends in their data and efficiently communicate these results with their peers. Modern C++ is being used for a variety of scientific applications, and this environment can benefit considerably from graphics libraries that attend the typical design goals toward scientific data visualization. Besides the option of exporting results to other environments, the customary alternatives in C++ are either non-dedicated libraries that depend on existing user interfaces or bindings to other languages. Matplot++ is a graphics library for data visualization that provides interactive plotting, means for exporting plots in high-quality formats for scientific publications, a compact syntax consistent with similar libraries, dozens of plot categories with specialized algorithms, multiple coding styles, and supports generic backends.


Build Status Latest Release Documentation Discussions


Facebook QZone Weibo Reddit Twitter LinkedIn WhatsApp Line.me Telegram.me HackerNews


READ THE DOCUMENTATION FOR A QUICK START AND EXAMPLES

Table of Contents

Gallery

example_plot_1 example_plot3_1 example_stairs_1 example_errorbar_1 example_area_1 example_loglog_1 example_fplot_1 example_fimplicit_1 example_histogram_1 example_boxplot_1 example_scatter_1 example_scatter3_1 example_binscatter_1 example_plotmatrix_1 example_parallelplot_1 example_pie_1 example_heatmap_1 example_wordcloud_1 example_bar_1 example_pareto_1 example_stem_1 example_stem3_1 example_geoplot_1 example_geoscatter_1 example_geobubble_1 example_geodensityplot_1 example_polarplot_1 example_polarscatter_1 example_polarhistogram_1 example_compass_1 example_ezpolar_1 example_contour_1 example_contourf_1 example_fcontour_1 example_feather_1 example_quiver_1 example_surf_1 example_surfc_1 example_mesh_1 example_meshc_1 example_meshz_1 example_fsurf_1 example_fmesh_1 example_waterfall_1 example_fence_1 example_ribbon_1 example_graph_1 example_digraph_1 example_imshow_1 example_image_1 example_imagesc_1

Complete Gallery

example_plot_1 example_plot_2 example_plot_3 example_plot_4 example_plot_5 example_plot_6 example_plot_7 example_plot_8 example_plot_9 example_plot_10 example_plot_11 example_plot_12 example_plot3_1 example_plot3_2 example_plot3_3 example_plot3_4 example_plot3_5 example_plot3_6 example_plot3_7 example_plot3_8 example_plot3_9 example_plot3_10 example_stairs_1 example_stairs_2 example_stairs_3 example_stairs_4 example_stairs_5 example_stairs_6 example_stairs_7 example_stairs_8 example_stairs_9 example_stairs_10 example_errorbar_1 example_errorbar_2 example_errorbar_3 example_errorbar_4 example_errorbar_5 example_errorbar_6 example_errorbar_7 example_errorbar_8 example_errorbar_9 example_errorbar_10 example_area_1 example_area_2 example_area_3 example_area_4 example_loglog_1 example_loglog_2 example_loglog_3 example_loglog_4 example_loglog_5 example_loglog_6 example_loglog_7 example_loglog_8 example_loglog_9 example_semilogx_1 example_semilogy_1 example_fplot_1 example_fplot_2 example_fplot_3 example_fplot_4 example_fplot_5 example_fplot_6 example_fplot3_1 example_fplot3_2 example_fplot3_3 example_fplot3_4 example_fplot3_5 example_fimplicit_1 example_fimplicit_2 example_fimplicit_3 example_fimplicit_4 example_histogram_1 example_histogram_2 example_histogram_3 example_histogram_4 example_histogram_5 example_histogram_6 example_histogram_7 example_histogram_8 example_histogram_9 example_histogram_10 example_histogram_11 example_histogram_12 example_histogram_14 example_boxplot_1 example_boxplot_2 example_boxplot_3 example_scatter_1 example_scatter_2 example_scatter_3 example_scatter_4 example_scatter_5 example_scatter_6 example_scatter_7 example_scatter_8 example_scatter3_1 example_scatter3_2 example_scatter3_3 example_scatter3_4 example_scatter3_5 example_scatter3_6 example_binscatter_1 example_binscatter_2 example_binscatter_3 example_binscatter_4 example_binscatter_5 example_binscatter_6 example_binscatter_7 example_plotmatrix_1 example_plotmatrix_2 example_plotmatrix_3 example_plotmatrix_4 example_parallelplot_1 example_parallelplot_2 example_parallelplot_3 example_pie_1 example_pie_2 example_pie_3 example_pie_4 example_pie_5 example_pie_6 example_heatmap_1 example_heatmap_2 example_heatmap_3 example_heatmap_4 example_heatmap_5 example_heatmap_6 example_heatmap_7 example_wordcloud_1 example_wordcloud_3 example_wordcloud_4 example_wordcloud_4 example_bar_1 example_bar_2 example_bar_3 example_bar_4 example_bar_5 example_bar_6 example_bar_7 example_bar_8 example_bar_9 example_bar_10 example_bar_11 example_bar_12 example_bar_13 example_pareto_1 example_pareto_2 example_pareto_3 example_pareto_4 example_stem_1 example_stem_2 example_stem_3 example_stem_4 example_stem_5 example_stem_6 example_stem_7 example_stem_8 example_stem_9 example_stem3_1 example_stem3_2 example_stem3_3 example_stem3_4 example_stem3_5 example_stem3_6 example_stem3_7 example_stem3_8 example_stem3_9 example_stem3_10 example_stem3_11 example_geoplot_1 example_geoplot_2 example_geoplot_3 example_geoplot_4 example_geoplot_5 example_geoplot_6 example_geoplot_7 example_geoscatter_1 example_geoscatter_2 example_geobubble_1 example_geobubble_2 example_geodensityplot_1 example_polarplot_1 example_polarplot_2 example_polarplot_3 example_polarplot_4 example_polarplot_5 example_polarplot_6 example_polarplot_7 example_polarplot_8 example_polarscatter_1 example_polarscatter_2 example_polarscatter_3 example_polarscatter_4 example_polarscatter_5 example_polarscatter_6 example_polarhistogram_1 example_polarhistogram_2 example_polarhistogram_3 example_polarhistogram_4 example_polarhistogram_5 example_compass_1 example_compass_2 example_ezpolar_1 example_ezpolar_2 example_contour_1 example_contour_2 example_contour_3 example_contour_4 example_contour_5 example_contour_6 example_contour_7 example_contour_8 example_contourf_1 example_contourf_2 example_contourf_3 example_contourf_4 example_contourf_5 example_contourf_6 example_fcontour_1 example_fcontour_2 example_fcontour_3 example_fcontour_4 example_fcontour_5 example_fcontour_6 example_fcontour_7 example_fcontour_8 example_fcontour_9 example_fcontour_10 example_fcontour_11 example_feather_1 example_quiver_1 example_quiver_2 example_quiver_3 example_quiver_4 example_quiver_5 example_quiver3_1 example_surf_1 example_surf_2 example_surf_3 example_surf_4 example_surf_5 example_surf_6 example_surfc_1 example_surfc_2 example_surfc_3 example_surfc_4 example_mesh_1 example_mesh_2 example_mesh_3 example_mesh_4 example_meshc_1 example_meshc_2 example_meshc_3 example_meshz_1 example_meshz_2 example_meshz_3 example_fsurf_1 example_fsurf_2 example_fsurf_3 example_fsurf_4 example_fsurf_5 example_fsurf_6 example_fsurf_7 example_fsurf_8 example_fmesh_1 example_fmesh_2 example_fmesh_3 example_fmesh_4 example_waterfall_1 example_waterfall_2 example_waterfall_3 example_fence_1 example_fence_2 example_fence_3 example_ribbon_1 example_ribbon_2 example_ribbon_3 example_ribbon_4 example_graph_1 example_graph_2 example_graph_3 example_graph_4 example_graph_5 example_graph_6 example_digraph_1 example_digraph_2 example_digraph_3 example_imshow_1 example_imshow_2 example_imshow_3 example_imshow_4 example_imshow_5 example_imshow_6 example_imshow_7 example_imshow_8 example_imshow_9 example_imshow_10 example_imshow_11 example_image_1 example_image_2 example_image_3 example_image_4 example_image_5 example_imagesc_1 example_imagesc_2 example_imagesc_3 example_imagesc_4 example_text_1 example_text_2 example_text_3 example_text_4 example_text_5 example_text_6 example_text_7 example_text_8 example_textarrow_1 example_textarrow_2 example_rectangle_1 example_rectangle_2 example_rectangle_3 example_rectangle_4 example_rectangle_5 example_fill_1 example_ellipse_1 example_textbox_1 example_arrow_1 example_arrow_2 example_line_1 example_title_1 example_title_2 example_title_3 example_title_4 example_title_5 example_title_6 example_title_7 example_title_8 example_sgtitle_1 example_sgtitle_2 example_xlabel_1 example_xlabel_2 example_xlabel_3 example_xlabel_4 example_xlabel_5 example_xlabel_6 example_xlabel_7 example_xlabel_8 example_ylabel_1 example_ylabel_2 example_ylabel_3 example_ylabel_4 example_ylabel_5 example_ylabel_6 example_ylabel_7 example_ylabel_8 example_zlabel_1 example_zlabel_2 example_zlabel_3 example_legend_1 example_legend_2 example_legend_3 example_legend_4 example_legend_5 example_legend_6 example_legend_7 example_legend_8 example_legend_9 example_xlim_1 example_xlim_2 example_xlim_3 example_xlim_4 example_xlim_5 example_xlim_6 example_ylim_1 example_ylim_2 example_ylim_3 example_ylim_4 example_ylim_5 example_ylim_6 example_zlim_1 example_zlim_2 example_zlim_3 example_zlim_4 example_zlim_5 example_zlim_6 example_axis_1 example_axis_2 example_axis_3 example_axis_4 example_axis_5 example_axis_6 example_axis_7 example_axis_8 example_box_1 example_box_2 example_box_3 example_grid_1 example_grid_2 example_grid_3 example_grid_4 example_xticks_1 example_xticks_2 example_xticks_3 example_xticks_4 example_xticks_5 example_xticks_6 example_xticks_7 example_xticks_8 example_yticks_1 example_yticks_2 example_yticks_3 example_yticks_4 example_yticks_5 example_yticks_6 example_yticks_7 example_yticks_8 example_zticks_1 example_zticks_2 example_zticks_3 example_zticks_4 example_zticks_5 example_zticks_6 example_xticklabels_1 example_xticklabels_2 example_xticklabels_3 example_xticklabels_4 example_yticklabels_1 example_yticklabels_2 example_yticklabels_3 example_yticklabels_4 example_xtickformat_1 example_xtickformat_2 example_xtickformat_3 example_xtickformat_4 example_xtickformat_5 example_ytickformat_1 example_ytickformat_2 example_ytickformat_3 example_ytickformat_4 example_ytickformat_5 example_ztickformat_1 example_ztickformat_2 example_ztickformat_3 example_ztickformat_4 example_ztickformat_5 example_xtickangle_1 example_xtickangle_2 example_xtickangle_3 example_ytickangle_1 example_ytickangle_2 example_ytickangle_3 example_hold_1 example_hold_2 example_hold_3 example_hold_4 example_yyaxis_1 example_yyaxis_2 example_yyaxis_3 example_yyaxis_4 example_yyaxis_5 example_yyaxis_6 example_yyaxis_7 example_colororder_1 example_colororder_2 example_colororder_3 example_colororder_4 example_colororder_5 example_colororder_6 example_colororder_7 example_subplot_1 example_subplot_2 example_subplot_3 example_subplot_4 example_subplot_5 example_subplot_6 example_subplot_7 example_subplot_8 example_subplot_9 example_subplot_10 example_subplot_11 example_subplot_12 example_subplot_13 example_tiledlayout_1 example_tiledlayout_2 example_tiledlayout_3 example_tiledlayout_4 example_tiledlayout_5 example_tiledlayout_6 example_tiledlayout_7 example_tiledlayout_8 example_colormap_1 example_colormap_2 example_colormap_3 example_colormap_4 example_colormap_5 example_colormap_6 example_colormap_7 example_colormap_8 example_colormap_9 example_colorbar_1 example_colorbar_2 example_colorbar_3 example_colorbar_4 example_colorbar_5 example_colorbar_6 example_colorbar_7 example_rgbplot_1 example_rgbplot_2 example_view_1 example_view_2 example_view_3 example_view_4 example_view_5 example_view_6 example_lighting_1 example_lighting_2 example_lighting_3 example_lighting_4 example_lighting_5 example_lighting_6 example_figure_1 example_figure_2 example_figure_3 example_line_spec_1 example_axes_1 example_axes_2 example_axes_3 example_axes_4 example_cla_1 example_cla_2 example_cla_3 example_save_1 example_save_2 example_save_3 example_save_4 example_save_5 example_save_6 example_save_7 example_save_8

Integration

CMake

Embed as subdirectory

You can use Matplot++ directly in CMake projects as a subproject, without installing it. This is convenient if you are experimenting with this library for the first time or don't expect your users to have Matplot++ installed on their systems.

Check if you have Cmake 3.14+ installed:

cmake --version

Clone the whole project

git clone https://github.com/alandefreitas/matplotplusplus/

and add the subdirectory to your CMake project:

add_subdirectory(matplotplusplus)

When creating your executable, link the library to the targets you want:

add_executable(my_target main.cpp)
target_link_libraries(my_target PUBLIC matplot)

Add this header to your source files:

#include 

However, in larger projects, it's always recommended to look for Matplot++ with

find_package
before including it as a subdirectory to avoid ODR errors.

Embed with automatic download

FetchContent
is a CMake command that can automatically download the Matplot++ repository. Check if you have Cmake 3.14+ installed:
cmake --version

Include FetchContent in your CMake build script:

include(FetchContent)

Declare the source for the contents:

FetchContent_Declare(matplotplusplus
        GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus
        GIT_TAG origin/master # or whatever tag you want

Let CMake download the repository and include it as a subdirectory.

FetchContent_GetProperties(matplotplusplus)
if(NOT matplotplusplus_POPULATED)
    FetchContent_Populate(matplotplusplus)
    add_subdirectory(${matplotplusplus_SOURCE_DIR} ${matplotplusplus_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

When creating your executable, link the library to the targets you want:

add_executable(my_target main.cpp)
target_link_libraries(my_target PUBLIC matplot)

Then add this header to your source files:

#include 

However, in larger projects, it's always recommended to look for Matplot++ with

find_package
before including it as a subdirectory to avoid ODR errors.

Embed with CPM.cmake

CPM.cmake is a nice wrapper around the CMake

FetchContent
function.

Check if you have Cmake 3.14+ installed:

cmake --version

Install CPM.cmake and then use this command to add Matplot++ to your build script:

CPMAddPackage(
    NAME matplotplusplus
    GITHUB_REPOSITORY alandefreitas/matplotplusplus
    GIT_TAG origin/master # or whatever tag you want
)
# ...
target_link_libraries(my_target PUBLIC matplot)

Then add this header to your source files:

#include 

However, in larger projects, it's always recommended to look for Matplot++ with

find_package
before including it as a subdirectory to avoid ODR errors.

You can use:

option(CPM_USE_LOCAL_PACKAGES "Try `find_package` before downloading dependencies" ON)

in your build script to let CPM.cmake do that for you.

Find as External Package

If you have the library installed on your system, you can call

find_package()
from your CMake build script.
find_package(Matplot++ REQUIRED)

When creating your executable, link the library to the targets you want:

add_executable(my_target main.cpp)
target_link_libraries(my_target PUBLIC Matplot++::matplot)

Then add this header to your source files:

#include 

You can see a complete example in

test/integration/CMakeLists.txt
.

CMake should be able to locate the

matplot++-config.cmake
script automatically if you installed the library under
/usr/local/
(Linux / Mac OS). Unfortunately, there is no easy default directory for
find_package
on Windows.

!!! warning "Default directories"

By default, the library is likely to be in `/usr/local/` (Linux / Mac OS) or `C:/Program Files/` (Windows). The installer will try to find the directory where you usually keep your libraries but that's not always perfect.

!!! warning "Finding packages on Windows"

Unfortunately, CMake does not have a single default directory for packages on Windows like `/usr/local/lib`. If CMake cannot find Matplot++ on Windows or if you installed the library outside the default directory on Linux/Mac OS, there are a few [options](https://stackoverflow.com/questions/21314893/what-is-the-default-search-path-for-find-package-in-windows-using-cmake):

  • Environment Variables: The most reliable way to set this default directory is through environment variables. You can create an environment variable MATPLOTPP_DIR and then add $ENV{MATPLOTPP_DIR} to the HINTS section of the find_package command. This tends to be more convenient than requiring the path on the command line every time. Starting with version 3.12, CMake now implicitly considers the <packagename>_Root environment variable a HINT for every find_package call.
  • Package Registry: CMake offers the Package Registry as an alternative mechanism for finding package locations. CMake maintains a list of package information in the Windows registry under HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\.
  • Append CMAKE_MODULE_PATH: You can append more directories to CMAKE_MODULE_PATH with something like list(APPEND CMAKE_MODULE_PATH "C:\\Program Files\\matplotplusplus 1.0.1"). CMAKE_MODULE_PATH is a list of search paths for CMake modules to be loaded by the include() or find_package() commands.
  • Set the DIR variable directly: Directly set the Matplot++_DIR variable with something like set(Matplot++_DIR "C:\\Program Files\\matplotplusplus 1.0.1\\lib\\cmake\\Matplot++"). This might be good enough for small local projects but it is hard-coding the directory in your build script. When your library gets out of your local environment, you need to choose one of the other options above (better) or make this variable an option and require the user to provide the directory on the command line every time (worse).

Supporting Both

It's often useful to let your build script download Matplot++ when findpackage fails. If using CPM.cmake, you can set the `CPMUSELOCALPACKAGES

option to try to
find_package(Matplot++)` before download Matplot++.

If using FetchContent, you can use the following pattern:

find_package(Matplot++ QUIET)
if(NOT Matplot++_FOUND)
    # Put your FetchContent or CPM.cmake script here
endif()

Install

Binary Packages

Get the binary package from the release section. These binaries refer to the last release version of Matplot++.

If you need a more recent version of Matplot++, you can download the binary packages from the CI artifacts or build the library from the source files.

Package Managers

Homebrew

Mac users can install Matplot++ with Homebrew:

brew install matplotplusplus

This formula is a contribution to Homebrew by Andrew Kane.

Arch Linux

Matplot++ is available in the Arch User Repository (AUR) as

matplotplusplus
.

Note you can manually install the package by following the instructions on the Arch Wiki or use an AUR helper like

yay
(recommended for ease of install).

yay -S matplotplusplus

To discuss any issues related to this package refer to the comments section on the AUR page of

matplotplusplus
here.

Build from Source

Dependencies

C++17

Make sure your C++ compiler supports C++17:

=== "Ubuntu + GCC"

```bash
g++ --version
```

=== "Mac Os + Clang"

```bash
clang --version
```

=== "Windows + MSVC"

!!! warning ""
    * Visit the [Visual Studio](https://visualstudio.microsoft.com) website
    * Download Git from [https://git-scm.com/download/win](https://git-scm.com/download/win) and install it

The output should be something like:

=== "Ubuntu + GCC"

```console
g++-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
```

=== "Mac Os + Clang"

```console
Apple clang version 11.0.0 (clang-1100.0.33.8)
```

=== "Windows + MSVC"

!!! warning ""
    * Visit the [Visual Studio](https://visualstudio.microsoft.com) website
    * Download Git from [https://git-scm.com/download/win](https://git-scm.com/download/win) and install it

If you need to update your compiler:

=== "Ubuntu + GCC"

```bash
# install GCC-8
sudo apt update
sudo apt install gcc-8
sudo apt install g++-8
```

To update to any other version, like GCC-9 or GCC-10:

sudo apt install build-essential
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install g++-10

Once you installed a newer version of GCC, you can link it to update-alternatives. For instance, if you have GCC-7 and GCC-10, you can link them with:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10

You can now use update-alternatives to set your default gcc and g++ to a more recent version:

update-alternatives --config g++
update-alternatives --config gcc

=== "Mac Os + Clang"

```bash
# download clang
curl --output clang.tar.xz -L https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang+llvm-11.0.0-x86_64-apple-darwin.tar.xz
mkdir clang
tar -xvJf clang.tar.xz -C clang

copy files to /usr/local

cd clang/clang+llvm-11.0.0-x86_64-apple-darwin sudo cp -R * /usr/local/

update default compiler

export CXX=/usr/local/bin/clang++

</pre>
<p>=== "Windows + MSVC"</p>
<pre>!!! warning ""
    * Visit the [Visual Studio](https://visualstudio.microsoft.com) website
    * Download Git from [https://git-scm.com/download/win](https://git-scm.com/download/win) and install it
</pre>
<p><strong>CMake 3.14+</strong></p>

<p>Also check your CMake version is at least 3.14+:</p>

<p>=== "Ubuntu + GCC"</p>
<pre>```bash
cmake --version

=== "Mac Os + Clang"

```bash
cmake --version
```

=== "Windows + MSVC"

```bash
cmake --version
```

If CMake is not installed or its version is older than CMake 3.14, update it with

=== "Ubuntu + GCC"

```bash
sudo apt upgrade cmake
```

!!! warning "" Alternatively, download the most recent version from cmake.org.

=== "Mac Os + Clang"

```bash
sudo brew upgrade cmake
```

!!! warning "Homebrew" If this command fails because you don't have Homebrew on your computer, you can install it with

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

or you can follow the instructions in [https://brew.sh](https://brew.sh).

!!! warning "" Alternatively, download the most recent version from cmake.org.

=== "Windows + MSVC"

!!! warning ""
    Download the most recent version from [cmake.org](https://cmake.org/).

Gnuplot 5.2.6+

Install Gnuplot 5.2.6+ (Required at runtime)

=== "Ubuntu + GCC"

```bash
sudo apt update
sudo apt install gnuplot
```

!!! note "" Or download the latest version from www.gnuplot.info. If you're using an installer, make sure you mark the option "Add application directory to your PATH environment variable".

=== "Mac Os + Clang"

```bash
sudo brew install gnuplot
```

!!! note "" Or download the latest version from www.gnuplot.info. If you're using an installer, make sure you mark the option "Add application directory to your PATH environment variable".

=== "Windows + MSVC"

!!! warning ""
    Download Gnuplot from [www.gnuplot.info](http://www.gnuplot.info) and install it.

If you're using the Gnuplot installer, make sure you mark the option "Add application directory to your PATH environment variable"

!!! warning "Windows Gnuplot Terminals"

If the Matplot++ examples don't display without console errors and gnuplot running, try to re-install Gnuplot with the wxt terminal.

Optional Dependencies

The build script will also look for these optional dependencies for manipulating images:

  • JPEG
  • TIFF
  • ZLIB
  • PNG
  • LAPACK
  • BLAS
  • FFTW
  • OpenCV

Embedded dependencies

There are two dependencies in

source/3rd_party
. These dependencies are bundled, so you don't have to worry about them:

  • olvb/nodesoup
  • dtschump/CImg

You can define

WITH_SYSTEM_NODESOUP=ON
or
WITH_SYSTEM_CIMG=ON
in the cmake command line to use a system-provided version of these dependencies.

OpenGL dependencies

There's an extra target

matplot_opengl
with the experimental OpenGL backend. You need to define
BUILD_EXPERIMENTAL_OPENGL_BACKEND=ON
in the CMake command line to build that target. In that case, the build script will also look for these extra dependencies:
  • OpenGL
  • GLAD
  • GLFW3

If these dependencies are not found, the build script will download them. In any case, you can install these dependencies with:

=== "Ubuntu + GCC"

```bash
sudo apt-get install libglfw3-dev
```

=== "Mac Os + Clang"

!!! note ""
    Download GLFW3 from https://www.glfw.org

=== "Windows + MSVC"

!!! note ""
    Download GLFW3 from https://www.glfw.org

You can also see all dependencies in

source/3rd_party/CMakeLists.txt
.

Build and install

Building Examples

This will build the examples in the

build/examples
directory:

=== "Ubuntu + GCC"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2"
sudo cmake --build . --parallel 2 --config Release
```

=== "Mac Os + Clang"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2"
cmake --build . --parallel 2 --config Release
```

=== "Windows + MSVC"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="/O2"
cmake --build . --parallel 2 --config Release
```

!!! hint "Parallel Build" Replace

--parallel 2
with
--parallel 

!!! note "Setting C++ Compiler"

If your C++ compiler that supports C++17 is not your default compiler, make sure you provide CMake with the compiler location with the DCMAKE_C_COMPILER and DCMAKE_CXX_COMPILER options. For instance:

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2" -DCMAKE_C_COMPILER=/usr/bin/gcc-8 -DCMAKE_CXX_COMPILER=/usr/bin/g++-8

Installing

You can 1) use

-DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF
to bypass the examples and tests, and then 2)
cmake --install .
to install Matplot++ on your system:

=== "Ubuntu + GCC"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2" -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF 
sudo cmake --build . --parallel 2 --config Release
sudo cmake --install .
```

=== "Mac Os + Clang"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O2" -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF 
cmake --build . --parallel 2 --config Release
cmake --install .
```

=== "Windows + MSVC"

```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="/O2" -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF 
cmake --build . --parallel 2 --config Release
cmake --install .
```

!!! hint "Parallel Build" Replace

--parallel 2
with
--parallel 

Create packages

You can also create the binary packages to install Matplot++ on other systems:

=== "Ubuntu + GCC"

```bash
sudo cpack .
```

=== "Mac Os + Clang"

```bash
cpack .
```

=== "Windows + MSVC"

```bash
cpack .
```

Plot Types

Line Plots

Line Plot | Line Plot 3D | Stairs | Error Bars | Area | Loglog Plot | Semilogx Plot | Semilogy Plot | Function Plot | Function Plot 3D | Implicit function <!-- END mdsplit-ignore -->

Line Plot

!!! tip Use these examples to understand how to quickly use the library for data visualization. If you are interested in understanding how the library works, you can later read the details in the complete article.

plot(x,y); 

Where

x
and
y
are are any value ranges.

READ THE DOCUMENTATION TO SEE THESE EXAMPLES WITH THE IMAGES

=== "Plot"

[![example_plot_1](docs/examples/line_plot/plot/plot_1.svg)](examples/line_plot/plot/plot_1.cpp)

=== "C++"

```cpp
--8


More examples

example_plot_2 example_plot_3 example_plot_4 example_plot_5 example_plot_6 example_plot_7 example_plot_8 example_plot_9 example_plot_10 example_plot_11 example_plot_12

!!! tip Setters return a reference to

*this
to allow method chaining:
```cpp
plot(x,y)->line_width(2).color("red");
```

!!! tip These examples use free-standing functions to create plots. You can also use a object-oriented style for plots. We discuss these coding styles in the Section Coding Styles.

More examples

===! "Plot"

[![example_plot_2](docs/examples/line_plot/plot/plot_2.svg)](examples/line_plot/plot/plot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_3](docs/examples/line_plot/plot/plot_3.svg)](examples/line_plot/plot/plot_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_4](docs/examples/line_plot/plot/plot_4.svg)](examples/line_plot/plot/plot_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_5](docs/examples/line_plot/plot/plot_5.svg)](examples/line_plot/plot/plot_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_6](docs/examples/line_plot/plot/plot_6.svg)](examples/line_plot/plot/plot_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_7](docs/examples/line_plot/plot/plot_7.svg)](examples/line_plot/plot/plot_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_8](docs/examples/line_plot/plot/plot_8.svg)](examples/line_plot/plot/plot_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_9](docs/examples/line_plot/plot/plot_9.svg)](examples/line_plot/plot/plot_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_10](docs/examples/line_plot/plot/plot_10.svg)](examples/line_plot/plot/plot_10.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_11](docs/examples/line_plot/plot/plot_11.svg)](examples/line_plot/plot/plot_11.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot_12](docs/examples/line_plot/plot/plot_12.svg)](examples/line_plot/plot/plot_12.cpp)

=== "C++"

```cpp
--8

Line Plot 3D

plot3(x,y);

=== "Plot"

[![example_plot3_1](docs/examples/line_plot/plot3/plot3_1.svg)](examples/line_plot/plot3/plot3_1.cpp)

=== "C++"

```cpp
--8

!!! tip With method chaining:

```cpp
plot3(x,y)->line_width(2).color("red");
```
More examples

example_plot3_2 example_plot3_3 example_plot3_4 example_plot3_5 example_plot3_7 example_plot3_8 example_plot3_9 example_plot3_10

More examples

===! "Plot"

[![example_plot3_2](docs/examples/line_plot/plot3/plot3_2.svg)](examples/line_plot/plot3/plot3_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_3](docs/examples/line_plot/plot3/plot3_3.svg)](examples/line_plot/plot3/plot3_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_4](docs/examples/line_plot/plot3/plot3_4.png)](examples/line_plot/plot3/plot3_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_5](docs/examples/line_plot/plot3/plot3_5.svg)](examples/line_plot/plot3/plot3_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_7](docs/examples/line_plot/plot3/plot3_7.svg)](examples/line_plot/plot3/plot3_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_8](docs/examples/line_plot/plot3/plot3_8.svg)](examples/line_plot/plot3/plot3_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_9](docs/examples/line_plot/plot3/plot3_9.svg)](examples/line_plot/plot3/plot3_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plot3_10](docs/examples/line_plot/plot3/plot3_10.svg)](examples/line_plot/plot3/plot3_10.cpp)

=== "C++"

```cpp
--8

Stairs

stairs(x,y);

The

stair
object renders the line with stairs between data points to denote discrete data.
See result

example_stairs_1

More examples:

example_stairs_2 example_stairs_3 example_stairs_4 example_stairs_5 example_stairs_6 example_stairs_7 example_stairs_8 example_stairs_9 example_stairs_10

===! "Plot"

[![example_stairs_2](docs/examples/line_plot/stairs/stairs_2.svg)](examples/line_plot/stairs/stairs_2.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_stairs_3](docs/examples/line_plot/stairs/stairs_3.svg)](examples/line_plot/stairs/stairs_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_4](docs/examples/line_plot/stairs/stairs_4.svg)](examples/line_plot/stairs/stairs_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_5](docs/examples/line_plot/stairs/stairs_5.svg)](examples/line_plot/stairs/stairs_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_6](docs/examples/line_plot/stairs/stairs_6.svg)](examples/line_plot/stairs/stairs_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_7](docs/examples/line_plot/stairs/stairs_7.svg)](examples/line_plot/stairs/stairs_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_8](docs/examples/line_plot/stairs/stairs_8.svg)](examples/line_plot/stairs/stairs_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_9](docs/examples/line_plot/stairs/stairs_9.svg)](examples/line_plot/stairs/stairs_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stairs_10](docs/examples/line_plot/stairs/stairs_10.svg)](examples/line_plot/stairs/stairs_10.cpp)

=== "C++"

```cpp
--8

Error Bars

errorbar(x,y,err);
See result

example_errorbar_1

More examples:

example_errorbar_2 example_errorbar_3 example_errorbar_4 example_errorbar_5 example_errorbar_6 example_errorbar_7 example_errorbar_8 example_errorbar_9 example_errorbar_10

===! "Plot"

[![example_errorbar_1](docs/examples/line_plot/errorbar/errorbar_1.svg)](examples/line_plot/errorbar/errorbar_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_errorbar_2](docs/examples/line_plot/errorbar/errorbar_2.svg)](examples/line_plot/errorbar/errorbar_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_3](docs/examples/line_plot/errorbar/errorbar_3.svg)](examples/line_plot/errorbar/errorbar_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_4](docs/examples/line_plot/errorbar/errorbar_4.svg)](examples/line_plot/errorbar/errorbar_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_5](docs/examples/line_plot/errorbar/errorbar_5.svg)](examples/line_plot/errorbar/errorbar_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_6](docs/examples/line_plot/errorbar/errorbar_6.svg)](examples/line_plot/errorbar/errorbar_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_7](docs/examples/line_plot/errorbar/errorbar_7.svg)](examples/line_plot/errorbar/errorbar_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_8](docs/examples/line_plot/errorbar/errorbar_8.svg)](examples/line_plot/errorbar/errorbar_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_9](docs/examples/line_plot/errorbar/errorbar_9.svg)](examples/line_plot/errorbar/errorbar_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_errorbar_10](docs/examples/line_plot/errorbar/errorbar_10.svg)](examples/line_plot/errorbar/errorbar_10.cpp)

=== "C++"

```cpp
--8

The

error bar
object includes extra lines to represent error around data points. Log plots are utility functions that adjust the x or y axes to a logarithmic scale.

Area

area(Y);
See result

example_area_1

More examples:

example_area_2 example_area_3 example_area_4

===! "Plot"

[![example_area_1](docs/examples/line_plot/area/area_1.svg)](examples/line_plot/area/area_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_area_2](docs/examples/line_plot/area/area_2.svg)](examples/line_plot/area/area_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_area_3](docs/examples/line_plot/area/area_3.svg)](examples/line_plot/area/area_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_area_4](docs/examples/line_plot/area/area_4.svg)](examples/line_plot/area/area_4.cpp)

=== "C++"

```cpp
--8

Loglog Plot

loglog(x,y);
See result

example_loglog_1

More examples:

example_loglog_2 example_loglog_3 example_loglog_4 example_loglog_5 example_loglog_6 example_loglog_7 example_loglog_8 example_loglog_9

===! "Plot"

  [![example_loglog_1](docs/examples/line_plot/loglog/loglog_1.svg)](examples/line_plot/loglog/loglog_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

  [![example_loglog_2](docs/examples/line_plot/loglog/loglog_2.svg)](examples/line_plot/loglog/loglog_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_3](docs/examples/line_plot/loglog/loglog_3.png)](examples/line_plot/loglog/loglog_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_4](docs/examples/line_plot/loglog/loglog_4.svg)](examples/line_plot/loglog/loglog_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_5](docs/examples/line_plot/loglog/loglog_5.png)](examples/line_plot/loglog/loglog_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_6](docs/examples/line_plot/loglog/loglog_6.svg)](examples/line_plot/loglog/loglog_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_7](docs/examples/line_plot/loglog/loglog_7.svg)](examples/line_plot/loglog/loglog_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_8](docs/examples/line_plot/loglog/loglog_8.svg)](examples/line_plot/loglog/loglog_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

  [![example_loglog_9](docs/examples/line_plot/loglog/loglog_9.svg)](examples/line_plot/loglog/loglog_9.cpp)

=== "C++"

```cpp
--8

Semilogx Plot

semilogx(x,y);
See result

example_semilogx_1

===! "Plot"

[![example_semilogx_1](docs/examples/line_plot/semilogx/semilogx_1.svg)](examples/line_plot/semilogx/semilogx_1.cpp)

=== "C++"

```cpp
--8

Semilogy Plot

semilogy(x,y);
See result

example_semilogy_1

===! "Plot"

[![example_semilogy_1](docs/examples/line_plot/semilogy/semilogy_1.svg)](examples/line_plot/semilogy/semilogy_1.cpp)

=== "C++"

```cpp
--8

Function Plot

fplot(fx);
See result

example_fplot_1

More examples:

example_fplot_2 example_fplot_3 example_fplot_4 example_fplot_5 example_fplot_6

===! "Plot"

[![example_fplot_1](docs/examples/line_plot/fplot/fplot_1.svg)](examples/line_plot/fplot/fplot_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_fplot_2](docs/examples/line_plot/fplot/fplot_2.svg)](examples/line_plot/fplot/fplot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot_3](docs/examples/line_plot/fplot/fplot_3.png)](examples/line_plot/fplot/fplot_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot_4](docs/examples/line_plot/fplot/fplot_4.png)](examples/line_plot/fplot/fplot_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot_5](docs/examples/line_plot/fplot/fplot_5.png)](examples/line_plot/fplot/fplot_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot_6](docs/examples/line_plot/fplot/fplot_6.svg)](examples/line_plot/fplot/fplot_6.cpp)

=== "C++"

```cpp
--8

Instead of storing data points, the objects

function line
and
string function
store a function as a lambda function or as a string with an expression. These objects use lazy evaluation to generate absolute data points. The data is generated only when the
draw
function is called.

Function Plot 3D

fplot(fxy);
See result

example_fplot3_1

More examples:

example_fplot3_2 example_fplot3_3 example_fplot3_4 example_fplot3_5

===! "Plot"

[![example_fplot3_1](docs/examples/line_plot/fplot3/fplot3_1.svg)](examples/line_plot/fplot3/fplot3_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_fplot3_2](docs/examples/line_plot/fplot3/fplot3_2.svg)](examples/line_plot/fplot3/fplot3_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot3_3](docs/examples/line_plot/fplot3/fplot3_3.png)](examples/line_plot/fplot3/fplot3_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot3_4](docs/examples/line_plot/fplot3/fplot3_4.svg)](examples/line_plot/fplot3/fplot3_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fplot3_5](docs/examples/line_plot/fplot3/fplot3_5.svg)](examples/line_plot/fplot3/fplot3_5.cpp)

=== "C++"

```cpp
--8

Implicit function

fplot(fxy);
See result

example_fimplicit_1

More examples:

example_fimplicit_2 example_fimplicit_3 example_fimplicit_4

===! "Plot"

[![example_fimplicit_1](docs/examples/line_plot/fimplicit/fimplicit_1.svg)](examples/line_plot/fimplicit/fimplicit_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_fimplicit_2](docs/examples/line_plot/fimplicit/fimplicit_2.svg)](examples/line_plot/fimplicit/fimplicit_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fimplicit_3](docs/examples/line_plot/fimplicit/fimplicit_3.svg)](examples/line_plot/fimplicit/fimplicit_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fimplicit_4](docs/examples/line_plot/fimplicit/fimplicit_4.svg)](examples/line_plot/fimplicit/fimplicit_4.cpp)

=== "C++"

```cpp
--8

Data Distribution

Histogram | Boxplot | Scatter Plot | Scatter Plot 3D | Binned Scatter Plots | Plot Matrix | Parallel Coordinates | Pie Chart | Heatmap | Word Cloud <!-- END mdsplit-ignore -->

Histogram

The

histogram
object creates the histogram edges and bins when the
draw
function is called for the first time with lazy evaluation. Lazy evaluation avoids calculating edges unnecessarily in case the user changes the object parameters before calling
draw
. This object includes several algorithms for automatically delimiting the edges and bins for the histograms.
hist(data);
See result

example_histogram_1

More examples:

example_histogram_2 example_histogram_3 example_histogram_4 example_histogram_5 example_histogram_6 example_histogram_7 example_histogram_8 example_histogram_9 example_histogram_10 example_histogram_11 example_histogram_12 example_histogram_14

===! "Plot"

[![example_histogram_1](docs/examples/data_distribution/histogram/histogram_1.png)](examples/data_distribution/histogram/histogram_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_histogram_2](docs/examples/data_distribution/histogram/histogram_2.png)](examples/data_distribution/histogram/histogram_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_3](docs/examples/data_distribution/histogram/histogram_3.png)](examples/data_distribution/histogram/histogram_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_4](docs/examples/data_distribution/histogram/histogram_4.png)](examples/data_distribution/histogram/histogram_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_5](docs/examples/data_distribution/histogram/histogram_5.png)](examples/data_distribution/histogram/histogram_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_6](docs/examples/data_distribution/histogram/histogram_6.png)](examples/data_distribution/histogram/histogram_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_7](docs/examples/data_distribution/histogram/histogram_7.svg)](examples/data_distribution/histogram/histogram_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_8](docs/examples/data_distribution/histogram/histogram_8.png)](examples/data_distribution/histogram/histogram_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_9](docs/examples/data_distribution/histogram/histogram_9.png)](examples/data_distribution/histogram/histogram_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_10](docs/examples/data_distribution/histogram/histogram_10.svg)](examples/data_distribution/histogram/histogram_10.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_11](docs/examples/data_distribution/histogram/histogram_11.svg)](examples/data_distribution/histogram/histogram_11.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_12](docs/examples/data_distribution/histogram/histogram_12.svg)](examples/data_distribution/histogram/histogram_12.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_histogram_14](docs/examples/data_distribution/histogram/histogram_14.png)](examples/data_distribution/histogram/histogram_14.cpp)

=== "C++"

```cpp
--8

Boxplot

boxplot(data);
See result

example_boxplot_1

More examples:

example_boxplot_2 example_boxplot_3

===! "Plot"

[![example_boxplot_1](docs/examples/data_distribution/boxplot/boxplot_1.svg)](examples/data_distribution/boxplot/boxplot_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_boxplot_2](docs/examples/data_distribution/boxplot/boxplot_2.svg)](examples/data_distribution/boxplot/boxplot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_boxplot_3](docs/examples/data_distribution/boxplot/boxplot_3.png)](examples/data_distribution/boxplot/boxplot_3.cpp)

=== "C++"

```cpp
--8

Scatter Plot

scatter(x,y);
See result

example_scatter_1

More examples:

example_scatter_2 example_scatter_3 example_scatter_4 example_scatter_5 example_scatter_6 example_scatter_7 example_scatter_8

===! "Plot"

[![example_scatter_1](docs/examples/data_distribution/scatter/scatter_1.svg)](examples/data_distribution/scatter/scatter_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_scatter_2](docs/examples/data_distribution/scatter/scatter_2.svg)](examples/data_distribution/scatter/scatter_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_3](docs/examples/data_distribution/scatter/scatter_3.svg)](examples/data_distribution/scatter/scatter_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_4](docs/examples/data_distribution/scatter/scatter_4.svg)](examples/data_distribution/scatter/scatter_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_5](docs/examples/data_distribution/scatter/scatter_5.svg)](examples/data_distribution/scatter/scatter_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_6](docs/examples/data_distribution/scatter/scatter_6.svg)](examples/data_distribution/scatter/scatter_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_7](docs/examples/data_distribution/scatter/scatter_7.svg)](examples/data_distribution/scatter/scatter_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter_8](docs/examples/data_distribution/scatter/scatter_8.svg)](examples/data_distribution/scatter/scatter_8.cpp)

=== "C++"

```cpp
--8

Scatter plots also depend on the

line
object. As the line object can represent lines with markers, the
scatter
function simply creates markers without the lines.

Scatter Plot 3D

scatter(x,y,z);
See result

example_scatter3_1

More examples:

example_scatter3_2 example_scatter3_3 example_scatter3_4 example_scatter3_5 example_scatter3_6

===! "Plot"

[![example_scatter3_1](docs/examples/data_distribution/scatter3/scatter3_1.svg)](examples/data_distribution/scatter3/scatter3_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_scatter3_2](docs/examples/data_distribution/scatter3/scatter3_2.svg)](examples/data_distribution/scatter3/scatter3_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter3_3](docs/examples/data_distribution/scatter3/scatter3_3.svg)](examples/data_distribution/scatter3/scatter3_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter3_4](docs/examples/data_distribution/scatter3/scatter3_4.svg)](examples/data_distribution/scatter3/scatter3_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter3_5](docs/examples/data_distribution/scatter3/scatter3_5.svg)](examples/data_distribution/scatter3/scatter3_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_scatter3_6](docs/examples/data_distribution/scatter3/scatter3_6.png)](examples/data_distribution/scatter3/scatter3_6.cpp)

=== "C++"

```cpp
--8

Binned Scatter Plots

binscatter(x,y);
See result

example_binscatter_1

More examples:

example_binscatter_2 example_binscatter_3 example_binscatter_4 example_binscatter_5 example_binscatter_6 example_binscatter_7

===! "Plot"

[![example_binscatter_1](docs/examples/data_distribution/binscatter/binscatter_1.png)](examples/data_distribution/binscatter/binscatter_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_binscatter_2](docs/examples/data_distribution/binscatter/binscatter_2.png)](examples/data_distribution/binscatter/binscatter_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_binscatter_3](docs/examples/data_distribution/binscatter/binscatter_3.png)](examples/data_distribution/binscatter/binscatter_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_binscatter_4](docs/examples/data_distribution/binscatter/binscatter_4.png)](examples/data_distribution/binscatter/binscatter_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_binscatter_5](docs/examples/data_distribution/binscatter/binscatter_5.png)](examples/data_distribution/binscatter/binscatter_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_binscatter_6](docs/examples/data_distribution/binscatter/binscatter_6.png)](examples/data_distribution/binscatter/binscatter_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_binscatter_7](docs/examples/data_distribution/binscatter/binscatter_7.svg)](examples/data_distribution/binscatter/binscatter_7.cpp)

=== "C++"

```cpp
--8

Binned scatter plots use variations of the histogram algorithms of the previous section as an extra step to place all the data into two-dimensional bins that can be represented with varying colors or sizes. This is useful when there are so many data points that a scatter plot would be impractical for visualizing the data.

Plot Matrix

plotmatrix(X);
See result

example_plotmatrix_1

More examples:

example_plotmatrix_2 example_plotmatrix_3 example_plotmatrix_4

===! "Plot"

[![example_plotmatrix_1](docs/examples/data_distribution/plotmatrix/plotmatrix_1.svg)](examples/data_distribution/plotmatrix/plotmatrix_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_plotmatrix_2](docs/examples/data_distribution/plotmatrix/plotmatrix_2.png)](examples/data_distribution/plotmatrix/plotmatrix_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plotmatrix_3](docs/examples/data_distribution/plotmatrix/plotmatrix_3.png)](examples/data_distribution/plotmatrix/plotmatrix_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_plotmatrix_4](docs/examples/data_distribution/plotmatrix/plotmatrix_4.svg)](examples/data_distribution/plotmatrix/plotmatrix_4.cpp)

=== "C++"

```cpp
--8

The Plot Matrix subcategory is a combination of histograms and scatter plots. It creates a matrix of

axes
objects on the
figure
and creates a scatter plot for each pair of data sets.

Parallel Coordinates

parallelplot(X);
See result

example_parallelplot_1

More examples:

example_parallelplot_2 example_parallelplot_3

===! "Plot"

[![example_parallelplot_1](docs/examples/data_distribution/parallelplot/parallelplot_1.svg)](examples/data_distribution/parallelplot/parallelplot_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_parallelplot_2](docs/examples/data_distribution/parallelplot/parallelplot_2.svg)](examples/data_distribution/parallelplot/parallelplot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_parallelplot_3](docs/examples/data_distribution/parallelplot/parallelplot_3.svg)](examples/data_distribution/parallelplot/parallelplot_3.cpp)

=== "C++"

```cpp
--8

The function

parallelplot
creates a plot with Parallel Coordinates. In this type of plot, a
parallel lines
object stores an arbitrary set of
axis
objects to represent multi-dimensional data.

Pie Chart

pie(x);
See result

example_pie_1

More examples:

example_pie_2 example_pie_3 example_pie_4 example_pie_5 example_pie_6

===! "Plot"

[![example_pie_1](docs/examples/data_distribution/pie/pie_1.svg)](examples/data_distribution/pie/pie_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_pie_2](docs/examples/data_distribution/pie/pie_2.svg)](examples/data_distribution/pie/pie_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pie_3](docs/examples/data_distribution/pie/pie_3.svg)](examples/data_distribution/pie/pie_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pie_4](docs/examples/data_distribution/pie/pie_4.svg)](examples/data_distribution/pie/pie_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pie_5](docs/examples/data_distribution/pie/pie_5.svg)](examples/data_distribution/pie/pie_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pie_6](docs/examples/data_distribution/pie/pie_6.svg)](examples/data_distribution/pie/pie_6.cpp)

=== "C++"

```cpp
--8

Heatmap

heatmap(data);
See result

example_heatmap_1

More examples:

example_heatmap_2 example_heatmap_3 example_heatmap_4 example_heatmap_5 example_heatmap_6 example_heatmap_7

===! "Plot"

[![example_heatmap_1](docs/examples/data_distribution/heatmap/heatmap_1.png)](examples/data_distribution/heatmap/heatmap_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_heatmap_2](docs/examples/data_distribution/heatmap/heatmap_2.png)](examples/data_distribution/heatmap/heatmap_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_heatmap_3](docs/examples/data_distribution/heatmap/heatmap_3.png)](examples/data_distribution/heatmap/heatmap_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_heatmap_4](docs/examples/data_distribution/heatmap/heatmap_4.png)](examples/data_distribution/heatmap/heatmap_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_heatmap_5](docs/examples/data_distribution/heatmap/heatmap_5.png)](examples/data_distribution/heatmap/heatmap_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_heatmap_6](docs/examples/data_distribution/heatmap/heatmap_6.png)](examples/data_distribution/heatmap/heatmap_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_heatmap_7](docs/examples/data_distribution/heatmap/heatmap_7.png)](examples/data_distribution/heatmap/heatmap_7.cpp)

=== "C++"

```cpp
--8

Word Cloud

wordcloud(text, black_list);
See result

example_wordcloud_1

More examples:

example_wordcloud_3 example_wordcloud_4 example_wordcloud_4

===! "Plot"

[![example_wordcloud_1](docs/examples/data_distribution/wordcloud/wordcloud_1.png)](examples/data_distribution/wordcloud/wordcloud_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_wordcloud_3](docs/examples/data_distribution/wordcloud/wordcloud_3.png)](examples/data_distribution/wordcloud/wordcloud_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_wordcloud_4](docs/examples/data_distribution/wordcloud/wordcloud_4.png)](examples/data_distribution/wordcloud/wordcloud_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_wordcloud_4](docs/examples/data_distribution/wordcloud/wordcloud_4.png)](examples/data_distribution/wordcloud/wordcloud_4.cpp)

=== "C++"

```cpp
--8

Word clouds are generated from text or pairs of words and their frequency. After attributing a size proportional to each word frequency, the algorithm to position the labels iterates words from the largest to the smallest. For each word, it spins the word in polar coordinates converted to Cartesian coordinates until it does not overlap with any other word.

By default, the colors and the sizes depend on the word frequencies. We can customize the colors by passing a third parameter to the

wordcloud
function.

Discrete Data

Bar Plot | Pareto Chart | Stem Plot | Stem Plot 3D <!-- END mdsplit-ignore -->

Bar Plot

bar(y);
See result

example_bar_1

More examples:

example_bar_2 example_bar_3 example_bar_4 example_bar_5 example_bar_6 example_bar_7 example_bar_8 example_bar_9 example_bar_10 example_bar_11 example_bar_12 example_bar_13

===! "Plot"

[![example_bar_1](docs/examples/discrete_data/bar/bar_1.png)](examples/discrete_data/bar/bar_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_bar_2](docs/examples/discrete_data/bar/bar_2.png)](examples/discrete_data/bar/bar_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_3](docs/examples/discrete_data/bar/bar_3.png)](examples/discrete_data/bar/bar_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_4](docs/examples/discrete_data/bar/bar_4.png)](examples/discrete_data/bar/bar_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_5](docs/examples/discrete_data/bar/bar_5.png)](examples/discrete_data/bar/bar_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_6](docs/examples/discrete_data/bar/bar_6.png)](examples/discrete_data/bar/bar_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_7](docs/examples/discrete_data/bar/bar_7.svg)](examples/discrete_data/bar/bar_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_8](docs/examples/discrete_data/bar/bar_8.png)](examples/discrete_data/bar/bar_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_9](docs/examples/discrete_data/bar/bar_9.png)](examples/discrete_data/bar/bar_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_10](docs/examples/discrete_data/bar/bar_10.png)](examples/discrete_data/bar/bar_10.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_11](docs/examples/discrete_data/bar/bar_11.png)](examples/discrete_data/bar/bar_11.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_12](docs/examples/discrete_data/bar/bar_12.png)](examples/discrete_data/bar/bar_12.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_bar_13](docs/examples/discrete_data/bar/bar_13.png)](examples/discrete_data/bar/bar_13.cpp)

=== "C++"

```cpp
--8

Pareto Chart

pareto(y);
See result

example_pareto_1

More examples:

example_pareto_2 example_pareto_3 example_pareto_4

===! "Plot"

[![example_pareto_1](docs/examples/discrete_data/pareto/pareto_1.svg)](examples/discrete_data/pareto/pareto_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_pareto_2](docs/examples/discrete_data/pareto/pareto_2.svg)](examples/discrete_data/pareto/pareto_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pareto_3](docs/examples/discrete_data/pareto/pareto_3.svg)](examples/discrete_data/pareto/pareto_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_pareto_4](docs/examples/discrete_data/pareto/pareto_4.svg)](examples/discrete_data/pareto/pareto_4.cpp)

=== "C++"

```cpp
--8

Pareto Charts are a type of chart that uses both axes. The axis is used to represent bars with the data values in descending order. The axis is used to represent the cumulative distribution function of the data in the axis. By default, a Pareto Chart includes up to 10 items or as many items as needed to represent 95% of the cumulative distribution.

If you need Pareto fronts rather than Pareto charts, we refer to Scatter Plots for two-dimensional fronts, Plot matrices for three-dimensional fronts, or Parallel Coordinate Plots for many-objective fronts. These plot subcategories are described in Section Data Distribution. If you also need a tool to calculate these fronts efficiently, we refer to the Pareto Front Library.

Stem Plot

stem(Y);
See result

example_stem_1

More examples:

example_stem_2 example_stem_3 example_stem_4 example_stem_5 example_stem_6 example_stem_7 example_stem_8 example_stem_9

===! "Plot"

[![example_stem_1](docs/examples/discrete_data/stem/stem_1.svg)](examples/discrete_data/stem/stem_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_stem_2](docs/examples/discrete_data/stem/stem_2.svg)](examples/discrete_data/stem/stem_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_3](docs/examples/discrete_data/stem/stem_3.svg)](examples/discrete_data/stem/stem_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_4](docs/examples/discrete_data/stem/stem_4.svg)](examples/discrete_data/stem/stem_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_5](docs/examples/discrete_data/stem/stem_5.svg)](examples/discrete_data/stem/stem_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_6](docs/examples/discrete_data/stem/stem_6.svg)](examples/discrete_data/stem/stem_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_7](docs/examples/discrete_data/stem/stem_7.svg)](examples/discrete_data/stem/stem_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_8](docs/examples/discrete_data/stem/stem_8.svg)](examples/discrete_data/stem/stem_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem_9](docs/examples/discrete_data/stem/stem_9.svg)](examples/discrete_data/stem/stem_9.cpp)

=== "C++"

```cpp
--8

Stem Plot 3D

stem3(z);
See result

example_stem3_1

More examples:

example_stem3_2 example_stem3_3 example_stem3_4 example_stem3_5 example_stem3_6 example_stem3_7 example_stem3_8 example_stem3_9 example_stem3_10 example_stem3_11

===! "Plot"

[![example_stem3_1](docs/examples/discrete_data/stem3/stem3_1.svg)](examples/discrete_data/stem3/stem3_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_stem3_2](docs/examples/discrete_data/stem3/stem3_2.svg)](examples/discrete_data/stem3/stem3_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_3](docs/examples/discrete_data/stem3/stem3_3.svg)](examples/discrete_data/stem3/stem3_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_4](docs/examples/discrete_data/stem3/stem3_4.svg)](examples/discrete_data/stem3/stem3_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_5](docs/examples/discrete_data/stem3/stem3_5.svg)](examples/discrete_data/stem3/stem3_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_6](docs/examples/discrete_data/stem3/stem3_6.svg)](examples/discrete_data/stem3/stem3_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_7](docs/examples/discrete_data/stem3/stem3_7.svg)](examples/discrete_data/stem3/stem3_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_8](docs/examples/discrete_data/stem3/stem3_8.svg)](examples/discrete_data/stem3/stem3_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_9](docs/examples/discrete_data/stem3/stem3_9.svg)](examples/discrete_data/stem3/stem3_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_10](docs/examples/discrete_data/stem3/stem3_10.svg)](examples/discrete_data/stem3/stem3_10.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_stem3_11](docs/examples/discrete_data/stem3/stem3_11.svg)](examples/discrete_data/stem3/stem3_11.cpp)

=== "C++"

```cpp
--8

Geography

Geoplot | Geoscatter Plot | Geobubble | Geodensity Plot <!-- END mdsplit-ignore -->

Geoplot

geoplot(lat,lon);
See result

example_geoplot_1

More examples:

example_geoplot_2 example_geoplot_3 example_geoplot_4 example_geoplot_5 example_geoplot_6 example_geoplot_7

===! "Plot"

[![example_geoplot_1](docs/examples/geography/geoplot/geoplot_1.png)](examples/geography/geoplot/geoplot_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_geoplot_2](docs/examples/geography/geoplot/geoplot_2.png)](examples/geography/geoplot/geoplot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_geoplot_3](docs/examples/geography/geoplot/geoplot_3.png)](examples/geography/geoplot/geoplot_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_geoplot_4](docs/examples/geography/geoplot/geoplot_4.png)](examples/geography/geoplot/geoplot_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_geoplot_5](docs/examples/geography/geoplot/geoplot_5.png)](examples/geography/geoplot/geoplot_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_geoplot_6](docs/examples/geography/geoplot/geoplot_6.png)](examples/geography/geoplot/geoplot_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_geoplot_7](docs/examples/geography/geoplot/geoplot_7.png)](examples/geography/geoplot/geoplot_7.cpp)

=== "C++"

```cpp
--8

For the first geography plot, Matplot++ calls

geoplot()
, which creates a filled polygon with the world map. This first plot receives the tag
"map"
so that subsequent geography plots recognize there is no need to recreate this world map.

The data for the world map comes from Natural Earth. They provide data at 1:10m, 1:50m, and 1:110m scales. The

geoplot
function will initially use the data at the 1:110m scales. The
geolimits
function can be used to update the axis limits for geography plots. The difference between the usual functions for adjusting axis limits (
xlim
and
ylim
) and
geolimits
is that the latter will also update the map resolution according to the new limits for the and axis.

The

geolimits
function will query the
figure
size and, depending on the new limits for the axes, update the map to the 1:10m, or 1:50m scales if needed. Because it would be very inefficient to render the whole world map at a 1:10m or 1:50m scale only to display a region of this map, the
geolimits
function also crops the data pertinent to the new region being displayed.

Note that this does not only involve removing data points outside the new limits but it also needs to create new data points on the correct borders to create new polygons coherent with the map entry points in the region. For this reason, the algorithm needs to track all submaps represented as closed polygons in the original world map. If submaps are completely inside or outside the new ranges, we can respectively include or dismiss the data points. However, if the submap is only partially inside the new limits, to generate the correct borders for the polygons, we need to track all points outside the limits to classify the directions of these points outside the limits. We do that by only including points that change quadrants around the new limits so that the map entry points create polygons that look like they would if the complete world map were still being rendered outside these new limits.

If the you are not interested in geographic plots, the build script includes an option to remove the high-resolution maps at 1:10m and 1:50m scales from the library. In this case, the library will always use the map at a 1:110m scale no matter the axis limits.

The function

world_cities
returns a list of major world cities. Its parameters define the minimum distances between cities in the and axes. The
greedy_tsp
function is a naive greedy algorithm to find a route between these cities as a Traveling Salesman Problem (TSP). We use the
geoplot
function to draw this route. Note that we use method chaining to define some further plot properties. Finally, the
text
function includes the city names in the map.

Geoscatter Plot

geoscatter(lat,lon);
See result

example_geoscatter_1

More examples:

example_geoscatter_2

===! "Plot"

[![example_geoscatter_1](docs/examples/geography/geoscatter/geoscatter_1.png)](examples/geography/geoscatter/geoscatter_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_geoscatter_2](docs/examples/geography/geoscatter/geoscatter_2.png)](examples/geography/geoscatter/geoscatter_2.cpp)

=== "C++"

```cpp
--8

Geobubble

geobubble(lat,lon,sizes);
See result

example_geobubble_1

More examples:

example_geobubble_2

===! "Plot"

[![example_geobubble_1](docs/examples/geography/geobubble/geobubble_1.png)](examples/geography/geobubble/geobubble_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_geobubble_2](docs/examples/geography/geobubble/geobubble_2.png)](examples/geography/geobubble/geobubble_2.cpp)

=== "C++"

```cpp
--8

Geodensity Plot

geodensityplot(lat, lon);
See result

example_geodensityplot_1

=== "Plot"

[![example_geodensityplot_1](docs/examples/geography/geodensityplot/geodensityplot_1.png)](examples/geography/geodensityplot/geodensityplot_1.cpp)

=== "C++"

```cpp
--8

Polar Plots

Polar Line Plot | Polar Scatter Plot | Polar Histogram | Compass | Polar Function <!-- END mdsplit-ignore -->

Polar Line Plot

polarplot(theta, rho);
See result

example_polarplot_1

More examples:

example_polarplot_2 example_polarplot_3 example_polarplot_4 example_polarplot_5 example_polarplot_6 example_polarplot_7 example_polarplot_8

===! "Plot"

[![example_polarplot_1](docs/examples/polar_plots/polarplot/polarplot_1.svg)](examples/polar_plots/polarplot/polarplot_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_polarplot_2](docs/examples/polar_plots/polarplot/polarplot_2.svg)](examples/polar_plots/polarplot/polarplot_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_3](docs/examples/polar_plots/polarplot/polarplot_3.svg)](examples/polar_plots/polarplot/polarplot_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_4](docs/examples/polar_plots/polarplot/polarplot_4.svg)](examples/polar_plots/polarplot/polarplot_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_5](docs/examples/polar_plots/polarplot/polarplot_5.svg)](examples/polar_plots/polarplot/polarplot_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_6](docs/examples/polar_plots/polarplot/polarplot_6.svg)](examples/polar_plots/polarplot/polarplot_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_7](docs/examples/polar_plots/polarplot/polarplot_7.svg)](examples/polar_plots/polarplot/polarplot_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarplot_8](docs/examples/polar_plots/polarplot/polarplot_8.svg)](examples/polar_plots/polarplot/polarplot_8.cpp)

=== "C++"

```cpp
--8

By emplacing a polar plot in the

axes
, the
axes
move to a polar mode, where we use the and axis instead of the and axis.

From the backend point of view, these axes are an abstraction to the user. The data points in the and axis are drawn by converting the positions from the polar coordinates and to the Cartesian coordinates and with the relationships and .

Aside from this conversion, these plot subcategories are analogous to line plots, scatter plots, histograms, quiver plots, and line functions.

Polar Scatter Plot

polarscatter(theta, rho);
See result

example_polarscatter_1

More examples:

example_polarscatter_2 example_polarscatter_3 example_polarscatter_4 example_polarscatter_5 example_polarscatter_6

===! "Plot"

[![example_polarscatter_1](docs/examples/polar_plots/polarscatter/polarscatter_1.svg)](examples/polar_plots/polarscatter/polarscatter_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_polarscatter_2](docs/examples/polar_plots/polarscatter/polarscatter_2.svg)](examples/polar_plots/polarscatter/polarscatter_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarscatter_3](docs/examples/polar_plots/polarscatter/polarscatter_3.svg)](examples/polar_plots/polarscatter/polarscatter_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarscatter_4](docs/examples/polar_plots/polarscatter/polarscatter_4.svg)](examples/polar_plots/polarscatter/polarscatter_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarscatter_5](docs/examples/polar_plots/polarscatter/polarscatter_5.svg)](examples/polar_plots/polarscatter/polarscatter_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarscatter_6](docs/examples/polar_plots/polarscatter/polarscatter_6.svg)](examples/polar_plots/polarscatter/polarscatter_6.cpp)

=== "C++"

```cpp
--8

Polar Histogram

polarhistogram(theta, 6);
See result

example_polarhistogram_1

More examples:

example_polarhistogram_2 example_polarhistogram_3 example_polarhistogram_4 example_polarhistogram_5

===! "Plot"

[![example_polarhistogram_1](docs/examples/polar_plots/polarhistogram/polarhistogram_1.svg)](examples/polar_plots/polarhistogram/polarhistogram_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_polarhistogram_2](docs/examples/polar_plots/polarhistogram/polarhistogram_2.svg)](examples/polar_plots/polarhistogram/polarhistogram_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarhistogram_3](docs/examples/polar_plots/polarhistogram/polarhistogram_3.svg)](examples/polar_plots/polarhistogram/polarhistogram_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarhistogram_4](docs/examples/polar_plots/polarhistogram/polarhistogram_4.svg)](examples/polar_plots/polarhistogram/polarhistogram_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_polarhistogram_5](docs/examples/polar_plots/polarhistogram/polarhistogram_5.svg)](examples/polar_plots/polarhistogram/polarhistogram_5.cpp)

=== "C++"

```cpp
--8

The function

polarhistogram
distributes the data into the number of bins provided as its second parameter.

Compass

compass(u, v);
See result

example_compass_1

More examples:

example_compass_2

===! "Plot"

[![example_compass_1](docs/examples/polar_plots/compass/compass_1.svg)](examples/polar_plots/compass/compass_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_compass_2](docs/examples/polar_plots/compass/compass_2.svg)](examples/polar_plots/compass/compass_2.cpp)

=== "C++"

```cpp
--8

Polar Function

ezpolar(fn);
See result

example_ezpolar_1

More examples:

example_ezpolar_2

===! "Plot"

[![example_ezpolar_1](docs/examples/polar_plots/ezpolar/ezpolar_1.svg)](examples/polar_plots/ezpolar/ezpolar_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_ezpolar_2](docs/examples/polar_plots/ezpolar/ezpolar_2.svg)](examples/polar_plots/ezpolar/ezpolar_2.cpp)

=== "C++"

```cpp
--8

Contour Plots

Contour | Filled Contour | Function Contour <!-- END mdsplit-ignore -->

Contour

contour(X, Y, Z);
See result

example_contour_1

More examples:

example_contour_2 example_contour_3 example_contour_4 example_contour_5 example_contour_6 example_contour_7 example_contour_8

===! "Plot"

[![example_contour_1](docs/examples/contour_plots/contour/contour_1.svg)](examples/contour_plots/contour/contour_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_contour_2](docs/examples/contour_plots/contour/contour_2.svg)](examples/contour_plots/contour/contour_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_3](docs/examples/contour_plots/contour/contour_3.svg)](examples/contour_plots/contour/contour_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_4](docs/examples/contour_plots/contour/contour_4.svg)](examples/contour_plots/contour/contour_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_5](docs/examples/contour_plots/contour/contour_5.svg)](examples/contour_plots/contour/contour_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_6](docs/examples/contour_plots/contour/contour_6.svg)](examples/contour_plots/contour/contour_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_7](docs/examples/contour_plots/contour/contour_7.svg)](examples/contour_plots/contour/contour_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contour_8](docs/examples/contour_plots/contour/contour_8.svg)](examples/contour_plots/contour/contour_8.cpp)

=== "C++"

```cpp
--8

All these subcategories depend on the

contours
type. They also depend on lazy evaluation for generating the contour lines. When the function
draw
is called in the
contours
class, it preprocesses all contour lines for a three-dimensional function.

Although it is relatively simple to show a heatmap with the values for the -axis, calculating contour lines relative to the -axis is more complex than it might seem at first. We provide the function

contourc
for calculating contour lines. This function uses an adaptation of the algorithm adopted by Matplotlib.

The algorithm creates a quad grid defined by the and values. It uses this grid to infer a contour line passing through positions with the same value. The algorithm sweeps through the grid twice to generate these lines. The first sweep looks for lines that start on the boundaries. The second sweep looks for interior closed loops.

Filled contours are closed polygons for pairs of contour levels. Some polygons for filled contours might be holes inside other polygons. The algorithm needs to keep track of these relationships so that we can render the polygons in their accurate order. To avoid an extra step that identifies this relationship between the polygons, the sweeping algorithm already identifies which polygons are holes for each level.

Once we find the quads with the contour line, the line is generated by interpolating the values around that quad.

Filled Contour

contourf(X, Y, Z);
See result

example_contourf_1

More examples:

example_contourf_2 example_contourf_3 example_contourf_4 example_contourf_5 example_contourf_6

===! "Plot"

[![example_contourf_1](docs/examples/contour_plots/contourf/contourf_1.svg)](examples/contour_plots/contourf/contourf_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_contourf_2](docs/examples/contour_plots/contourf/contourf_2.png)](examples/contour_plots/contourf/contourf_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contourf_3](docs/examples/contour_plots/contourf/contourf_3.png)](examples/contour_plots/contourf/contourf_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contourf_4](docs/examples/contour_plots/contourf/contourf_4.png)](examples/contour_plots/contourf/contourf_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contourf_5](docs/examples/contour_plots/contourf/contourf_5.png)](examples/contour_plots/contourf/contourf_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_contourf_6](docs/examples/contour_plots/contourf/contourf_6.svg)](examples/contour_plots/contourf/contourf_6.cpp)

=== "C++"

```cpp
--8

Function Contour

fcontour(f);
See result

example_fcontour_1

More examples:

example_fcontour_2 example_fcontour_3 example_fcontour_4 example_fcontour_5 example_fcontour_6 example_fcontour_7 example_fcontour_8 example_fcontour_9 example_fcontour_10 example_fcontour_11

===! "Plot"

[![example_fcontour_1](docs/examples/contour_plots/fcontour/fcontour_1.svg)](examples/contour_plots/fcontour/fcontour_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_fcontour_2](docs/examples/contour_plots/fcontour/fcontour_2.svg)](examples/contour_plots/fcontour/fcontour_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_3](docs/examples/contour_plots/fcontour/fcontour_3.svg)](examples/contour_plots/fcontour/fcontour_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_4](docs/examples/contour_plots/fcontour/fcontour_4.svg)](examples/contour_plots/fcontour/fcontour_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_5](docs/examples/contour_plots/fcontour/fcontour_5.svg)](examples/contour_plots/fcontour/fcontour_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_6](docs/examples/contour_plots/fcontour/fcontour_6.png)](examples/contour_plots/fcontour/fcontour_6.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_7](docs/examples/contour_plots/fcontour/fcontour_7.png)](examples/contour_plots/fcontour/fcontour_7.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_8](docs/examples/contour_plots/fcontour/fcontour_8.svg)](examples/contour_plots/fcontour/fcontour_8.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_9](docs/examples/contour_plots/fcontour/fcontour_9.png)](examples/contour_plots/fcontour/fcontour_9.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_10](docs/examples/contour_plots/fcontour/fcontour_10.png)](examples/contour_plots/fcontour/fcontour_10.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_fcontour_11](docs/examples/contour_plots/fcontour/fcontour_11.png)](examples/contour_plots/fcontour/fcontour_11.cpp)

=== "C++"

```cpp
--8

By default, the function

fcontour
will generate 9 contour lines from a lambda function. The functions
contour
and
contourf
, on the other hand, plot contour lines and filled contour lines from a grid of data points for , , and .

Vector Fields

Feather | Quiver | Quiver 3D <!-- END mdsplit-ignore -->

Quiver

quiver(x, y, u, v);
See result

example_quiver_1

More examples:

example_quiver_2 example_quiver_3 example_quiver_4

===! "Plot"

[![example_quiver_1](docs/examples/vector_fields/quiver/quiver_1.svg)](examples/vector_fields/quiver/quiver_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_quiver_2](docs/examples/vector_fields/quiver/quiver_2.svg)](examples/vector_fields/quiver/quiver_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_quiver_3](docs/examples/vector_fields/quiver/quiver_3.svg)](examples/vector_fields/quiver/quiver_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_quiver_4](docs/examples/vector_fields/quiver/quiver_4.svg)](examples/vector_fields/quiver/quiver_4.cpp)

=== "C++"

```cpp
--8

All these subcategories depend on the

vectors
object type. In a two-dimensional plot, for each value of and with the position of a vector, it also requires the value of and indicating its direction and magnitude. In a three-dimensional plot, the direction and magnitude are defined by , , and .

A quiver plot (or velocity plot) shows a grid of vectors whose direction and magnitude are scaled to prevent the overlap between vectors in subsequent quads.

Quiver 3D

quiver3(Z, U, V, W);
See result

example_quiver3_1

===! "Plot"

[![example_quiver3_1](docs/examples/vector_fields/quiver3/quiver3_1.svg)](examples/vector_fields/quiver3/quiver3_1.cpp)

=== "C++"

```cpp
--8

Feather

feather(u, v);
See result

example_feather_1

===! "Plot"

[![example_feather_1](docs/examples/vector_fields/feather/feather_1.svg)](examples/vector_fields/feather/feather_1.cpp)

=== "C++"

```cpp
--8

Surfaces

Surface | Surface with Contour | Mesh | Mesh with Contour | Mesh with Curtain | Function Surface | Function Mesh | Waterfall | Fence | Ribbon <!-- END mdsplit-ignore -->

Surface

surf(X, Y, Z);
See result

example_surf_1

More examples:

example_surf_2 example_surf_3 example_surf_4 example_surf_5 example_surf_6

===! "Plot"

[![example_surf_1](docs/examples/surfaces/surf/surf_1.png)](examples/surfaces/surf/surf_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_surf_2](docs/examples/surfaces/surf/surf_2.svg)](examples/surfaces/surf/surf_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surf_3](docs/examples/surfaces/surf/surf_3.svg)](examples/surfaces/surf/surf_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surf_4](docs/examples/surfaces/surf/surf_4.svg)](examples/surfaces/surf/surf_4.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surf_5](docs/examples/surfaces/surf/surf_5.svg)](examples/surfaces/surf/surf_5.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surf_6](docs/examples/surfaces/surf/surf_6.svg)](examples/surfaces/surf/surf_6.cpp)

=== "C++"

```cpp
--8

Surface with Contour

surfc(X, Y, Z);
See result

example_surfc_1

More examples:

example_surfc_2 example_surfc_3 example_surfc_4

===! "Plot"

[![example_surfc_1](docs/examples/surfaces/surfc/surfc_1.png)](examples/surfaces/surfc/surfc_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_surfc_2](docs/examples/surfaces/surfc/surfc_2.svg)](examples/surfaces/surfc/surfc_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surfc_3](docs/examples/surfaces/surfc/surfc_3.png)](examples/surfaces/surfc/surfc_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_surfc_4](docs/examples/surfaces/surfc/surfc_4.png)](examples/surfaces/surfc/surfc_4.cpp)

=== "C++"

```cpp
--8

Mesh

mesh(X, Y, Z);
See result

example_mesh_1

More examples:

example_mesh_2 example_mesh_3 example_mesh_4

===! "Plot"

[![example_mesh_1](docs/examples/surfaces/mesh/mesh_1.png)](examples/surfaces/mesh/mesh_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_mesh_2](docs/examples/surfaces/mesh/mesh_2.png)](examples/surfaces/mesh/mesh_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_mesh_3](docs/examples/surfaces/mesh/mesh_3.svg)](examples/surfaces/mesh/mesh_3.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_mesh_4](docs/examples/surfaces/mesh/mesh_4.svg)](examples/surfaces/mesh/mesh_4.cpp)

=== "C++"

```cpp
--8

Mesh with Contour

meshc(X, Y, Z);
See result

example_meshc_1

More examples:

example_meshc_2 example_meshc_3

===! "Plot"

[![example_meshc_1](docs/examples/surfaces/meshc/meshc_1.png)](examples/surfaces/meshc/meshc_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_meshc_2](docs/examples/surfaces/meshc/meshc_2.png)](examples/surfaces/meshc/meshc_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_meshc_3](docs/examples/surfaces/meshc/meshc_3.png)](examples/surfaces/meshc/meshc_3.cpp)

=== "C++"

```cpp
--8

Mesh with Curtain

meshz(X, Y, Z);
See result

example_meshz_1

More examples:

example_meshz_2 example_meshz_3

===! "Plot"

[![example_meshz_1](docs/examples/surfaces/meshz/meshz_1.png)](examples/surfaces/meshz/meshz_1.cpp)

=== "C++"

```cpp
--8

More examples

===! "Plot"

[![example_meshz_2](docs/examples/surfaces/meshz/meshz_2.png)](examples/surfaces/meshz/meshz_2.cpp)

=== "C++"

```cpp
--8

===! "Plot"

[![example_meshz_3](docs/examples/surfaces/meshz/meshz_3.png)](examples/surfaces/meshz/meshz_3.cpp)

=== "C++"

```cpp
--8

Function Surface

fsurf(fn);

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.