Skip to content

Commit 79c16b7

Browse files
committed
Rename documentation to docs
1 parent a902ab4 commit 79c16b7

File tree

1,254 files changed

+4529
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,254 files changed

+4529
-210
lines changed

README.md

Lines changed: 206 additions & 207 deletions
Large diffs are not rendered by default.

_config.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_site
2+
.jekyll-metadata
3+
Gemfile.lock

documentation/GALLERY.md renamed to docs/COMPLETE_GALLERY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
layout: default
3+
title: 404
4+
nav_exclude: true
5+
---
16
# Complete Gallery
27

38
## Line Plots

docs/Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6+
7+
# gem "rails"
8+
9+
gem "github-pages", group: :jekyll_plugins
10+
gem "just-the-docs"

documentation/README.md renamed to docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
layout: default
3+
title: Documentation
4+
nav_exclude: true
5+
---
16
# **Matplot++**
27

38
Data visualization can help programmers and scientists identify trends in their data and efficiently communicate these results with their peers.

docs/_config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
remote_theme: pmarsceill/just-the-docs
2+
#theme: "just-the-docs"
3+
title: Matplot++
4+
description: A C++ Graphics Library for Data Visualization 📊🗾
5+
6+
search_enabled: false
7+
8+
aux_links:
9+
"Matplot++ on GitHub":
10+
- "//github.com/alandefreitas/matplotplusplus"
11+
12+
footer_content: "Copyright &copy; Alan Freitas. Distributed by an <a href=\"https://github.com/alandefreitas/matplotplusplus/tree/master/LICENSE.txt\">MIT license.</a>"

docs/coding-styles.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
layout: default
3+
title: Coding styles
4+
nav_order: 4
5+
has_children: true
6+
has_toc: false
7+
---
8+
# Coding styles
9+
10+
11+
12+
- [Member vs. Free-standing Functions](coding-styles/member-vs-free-standing-functions.md)
13+
- [Reactive figures](coding-styles/reactive-figures.md)
14+
- [Method Chaining](coding-styles/method-chaining.md)
15+
- [Ranges](coding-styles/ranges.md)
16+
- [Common Utilities](coding-styles/common-utilities.md)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: default
3+
title: Common Utilities
4+
nav_order: 5
5+
has_children: false
6+
parent: Coding styles
7+
has_toc: false
8+
---
9+
# Common Utilities
10+
11+
The headers `common.h` and `colors.h` include a number of utilities we use in our examples. These include naive functions to generate and manipulate vectors and strings; handle RGBA color arrays; convert points to and from polar coordinates; read files to strings; write strings to files; calculate gradients; read, write, and manipulate images; and generate vectors with random numbers. Although some of these functions might be helpful, most functions only operate on `vector<double>` and they are not intended to be a library of utilities. The sole purpose of these algorithms is to simplify the examples.
12+
13+
14+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: default
3+
title: Member vs. Free-standing Functions
4+
nav_order: 1
5+
has_children: false
6+
parent: Coding styles
7+
has_toc: false
8+
---
9+
# Member vs. Free-standing Functions
10+
11+
Like in Matplotlib, we support two coding styles: Free-standing functions and an Object-oriented interface.
12+
13+
* Freestanding functions:
14+
- We call functions to create plots on the current axes
15+
- The global current `axes` object is the current `axes` object in the current figure in the global figure registry
16+
- For instance, one can use `plot(y);` to create a line plot on the current axes (or create a new `axes` object if needed).
17+
- Also, one can use `plot(ax,y);` to create a line plot on the `axes` object `ax`.
18+
- This is less verbose for small projects and quick tests.
19+
- The library looks for existing axes to create the plot.
20+
21+
* Object-oriented interface:
22+
- We explicitly create figures and call methods on them
23+
- For instance, one can use `ax->plot(y);` to plot on the `axes` object `ax`
24+
- We can create the same line plot on the current axes by `auto ax = gca(); ax->plot(y);`
25+
- This is less verbose and provides better control in large projects where we need to pass these objects around
26+
- The user manages axes handles containing plots.
27+
28+
Assuming the user is explicitly managing the axes to create plots in another function, a more complete example of these styles could be
29+
30+
```cpp
31+
// Free-standing functions
32+
auto ax = gca();
33+
plot(ax, x, y)->color("red").line_width(2);
34+
my_function(ax);
35+
```
36+
37+
and
38+
39+
```cpp
40+
// Object-oriented interface
41+
auto ax = gca();
42+
ax->plot(x, y)->color("red").line_width(2);
43+
my_function(ax);
44+
```
45+
46+
Both examples would generate the same plot. All free-standing functions are templated functions that use meta-programming to call the main function on the current `axes` object. If the first parameter is not an `axes_handle`, it will get an `axes_handle` from the figure registry with `gca` (Section [Axes Object](../examples/appearance/axes-object.md)) and forward all parameters to the function in this `axes` object. If the first parameter is an `axes_handle`, the template function will forward all parameters, but the first one, to this `axes` object. This use of templates for the free-standing functions keeps both coding styles maintainable by the developers.
47+
48+
Note that, because the example needs the `axes` object for the function `my_function`, we also need to get a reference to the `axes` object with the free-standing functions. In that case, the free-standing functions are not less verbose than the object-oriented interface.
49+
50+
To adhere to free-standing functions, we could create two versions of `my_function`: one that receives an `axes_handle`, and a second version that would get an `axes_handle` from the figure registry and call the first version. If `my_function` is going to be exposed to other users as a library, this could be a convenience to these users. However, notice that this is only moving the verbosity from the main function to `my_function`. In fact, this is how the free-standing functions in **Matplot++** work.
51+
52+
53+

0 commit comments

Comments
 (0)