3
3
The Docs
4
4
********
5
5
6
- .. _ STL vector : https://en.cppreference.com/w/cpp/container/vector
7
-
6
+ ` matplotlibcpp ` namespace
7
+ =========================
8
8
9
- .. _style :
10
9
11
- The style of a line
12
- ===================
10
+ All functions are organised in the namespace `matplotlibcpp `.
11
+ For convenience (and in spirit of the Python norm) we usually
12
+ define the abbreviation `plt `:
13
13
14
- The style of a line in a plot has three characteristics; the
15
- marker, the color and the line.
16
- They can be specified using the keywords map
17
- or the formatting string.
18
-
19
- They keywords map is a possibility to specify additional parameters
20
- for the plot commands. To set the line style it can be used as follows.
21
14
.. code-block :: cpp
22
15
23
- // for a red dashed line with circle markers
24
- plt::plot(x, y, {{"color", "red"}, {"marker": "o"}, {"linestyle": "--"}})
25
-
26
- // shorthand notation for color and linestyle is usually supported
27
- plt::plot(x, y, {{"c", "red"}, {"marker": "o"}, {"ls": "--"}})
28
-
29
- See sections `Marker `_, `Color `_ and `Line `_
30
- for supported values.
31
-
32
- The formatting string is a convenient notation to set the style of a line.
33
- Almost all plot commands support the formatting string as
34
- first argument after the `x ` and `y ` data.
35
-
36
- A formatting string's structure is
37
- ```
38
- s = "<marker><color><line>"
39
- ```
16
+ #include "matplotlibcpp.h"
17
+ namespace plt = matplotlibcpp;
40
18
41
- The rules are
42
-
43
- x. The valid parameters (``<> ``) are listed in the following sections.
44
-
45
- x. Different ordering of the parameters is supported.
46
- However, to avoid ambiguity this order should be used throughout.
47
-
48
- x. Parameters might be dropped.
49
-
50
- x. If only the colour parameters is specified, more color
51
- parameters are supported, see section `Color `_.
52
-
53
- **Examples **
19
+ The function can then be accessed via:
54
20
55
21
.. code-block :: cpp
56
22
57
- "b" // blue line
58
- "og" // green circles, no connecting line
59
- "og-" // green circles with connecting line
60
- "r--" // dashed red line
61
- "seagreen" // a solid line in the colour seagreen
62
- "#008000" // a solid line coloured in the HEX code
63
-
64
- The following sections list the supported markers, colours and linestyles.
65
-
66
- Marker
67
- ++++++
23
+ matplotlibcpp::plot(x, y);
24
+ plt::loglog(x, y); // if we defined namespace plt = matplotlibcpp
68
25
69
- ========= ======
70
- character marker
71
- ========= ======
72
- 'o' circle
73
- ========= ======
74
26
75
- Color
76
- +++++
77
-
78
- The color can be specified via a character code,
79
- a full name or a HEX code.
80
-
81
- .. note ::
82
-
83
- If a formatting string contains more parameters than just the color,
84
- only the character code is supported.
85
-
86
- Character code
87
- ^^^^^^^^^^^^^^
88
-
89
- ========= ======
90
- character color
91
- ========= ======
92
- 'r' red
93
- ========= ======
94
-
95
- Full name
96
- ^^^^^^^^^
97
-
98
- E.g. seagreen
99
-
100
- HEX code
101
- ^^^^^^^^
102
-
103
- Just use HEX
104
-
105
- Line
106
- ++++
107
-
108
- ========= ======
109
- character line
110
- ========= ======
111
- '-' solid
112
- ========= ======
27
+ `Vector ` type
28
+ =============
113
29
114
- The `Vector ` type
115
- =================
30
+ .. _STL vector : https://en.cppreference.com/w/cpp/container/vector
116
31
117
32
.. cpp :type :: Vector
118
33
@@ -157,14 +72,16 @@ The `Vector` type
157
72
Plot commands
158
73
=============
159
74
75
+ .. cpp :namespace :: matplotlibcpp
76
+
160
77
.. _mpl_plot : https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html
161
78
162
79
.. cpp :function ::
163
80
template <typename VectorX, typename VectorY> \
164
81
bool plot (const VectorX &x, const VectorY &y, const std::string &s = "", \
165
82
const std::map<std::string, std::string> &keywords = {})
166
83
167
- .. image :: ../matplotlib_icon.png
84
+ .. image :: ../img/ matplotlib_icon.png
168
85
:align: right
169
86
:width: 20px
170
87
:height: 20px
@@ -231,7 +148,7 @@ Plot commands
231
148
bool plot (const VectorY &y, const std::string &format = "", \
232
149
const std::map<std::string, std::string> &keywords = {})
233
150
234
- .. image :: ../matplotlib_icon.png
151
+ .. image :: ../img/ matplotlib_icon.png
235
152
:align: right
236
153
:width: 20px
237
154
:height: 20px
@@ -281,7 +198,7 @@ Plot commands
281
198
bool loglog (const VectorX &x, const VectorY &y, const std::string &s = "", \
282
199
const std::map<std::string, std::string> &keywords = {})
283
200
284
- .. image :: ../matplotlib_icon.png
201
+ .. image :: ../img/ matplotlib_icon.png
285
202
:align: right
286
203
:width: 20px
287
204
:height: 20px
@@ -326,7 +243,7 @@ Plot commands
326
243
bool loglog (const VectorY &y, const std::string &s = "", \
327
244
const std::map<std::string, std::string> &keywords = {})
328
245
329
- .. image :: ../matplotlib_icon.png
246
+ .. image :: ../img/ matplotlib_icon.png
330
247
:align: right
331
248
:width: 20px
332
249
:height: 20px
@@ -365,7 +282,7 @@ Plot commands
365
282
bool semilogx (const VectorX &x, const VectorY &y, const std::string &s = "", \
366
283
const std::map<std::string, std::string> &keywords = {})
367
284
368
- .. image :: ../matplotlib_icon.png
285
+ .. image :: ../img/ matplotlib_icon.png
369
286
:align: right
370
287
:width: 20px
371
288
:height: 20px
@@ -384,7 +301,7 @@ Plot commands
384
301
bool semilogx (const VectorY &y, const std::string &s = "", \
385
302
const std::map<std::string, std::string> &keywords = {})
386
303
387
- .. image :: ../matplotlib_icon.png
304
+ .. image :: ../img/ matplotlib_icon.png
388
305
:align: right
389
306
:width: 20px
390
307
:height: 20px
@@ -406,7 +323,7 @@ Plot commands
406
323
bool semilogy (const VectorX &x, const VectorY &y, const std::string &s = "", \
407
324
const std::map<std::string, std::string> &keywords = {})
408
325
409
- .. image :: ../matplotlib_icon.png
326
+ .. image :: ../img/ matplotlib_icon.png
410
327
:align: right
411
328
:width: 20px
412
329
:height: 20px
@@ -425,7 +342,7 @@ Plot commands
425
342
bool semilogy (const VectorY &y, const std::string &s = "", \
426
343
const std::map<std::string, std::string> &keywords = {})
427
344
428
- .. image :: ../matplotlib_icon.png
345
+ .. image :: ../img/ matplotlib_icon.png
429
346
:align: right
430
347
:width: 20px
431
348
:height: 20px
@@ -445,7 +362,7 @@ Plot commands
445
362
template <typename Numeric> \
446
363
void text (Numeric x, Numeric y, const std::string &s = "")
447
364
448
- .. image :: ../matplotlib_icon.png
365
+ .. image :: ../img/ matplotlib_icon.png
449
366
:align: right
450
367
:width: 20px
451
368
:height: 20px
@@ -487,7 +404,7 @@ Figure commands
487
404
.. cpp :function ::
488
405
inline long figure (long number = -1)
489
406
490
- .. image :: ../matplotlib_icon.png
407
+ .. image :: ../img/ matplotlib_icon.png
491
408
:align: right
492
409
:width: 20px
493
410
:height: 20px
@@ -523,7 +440,7 @@ Figure commands
523
440
inline void legend (const std::string &loc = "best", \
524
441
const Vector &bbox_to_anchor = Vector())
525
442
526
- .. image :: ../matplotlib_icon.png
443
+ .. image :: ../img/ matplotlib_icon.png
527
444
:align: right
528
445
:width: 20px
529
446
:height: 20px
@@ -556,7 +473,7 @@ Figure commands
556
473
template <typename Numeric> \
557
474
void xlim (Numeric left, Numeric right)
558
475
559
- .. image :: ../matplotlib_icon.png
476
+ .. image :: ../img/ matplotlib_icon.png
560
477
:align: right
561
478
:width: 20px
562
479
:height: 20px
@@ -574,7 +491,7 @@ Figure commands
574
491
template <typename Numeric> \
575
492
void ylim (Numeric bottom, Numeric top)
576
493
577
- .. image :: ../matplotlib_icon.png
494
+ .. image :: ../img/ matplotlib_icon.png
578
495
:align: right
579
496
:width: 20px
580
497
:height: 20px
@@ -608,7 +525,7 @@ Figure commands
608
525
inline void title (const std::string &titlestr, \
609
526
const std::map<std::string, std::string> &keywords = {})
610
527
611
- .. image :: ../matplotlib_icon.png
528
+ .. image :: ../img/ matplotlib_icon.png
612
529
:align: right
613
530
:width: 20px
614
531
:height: 20px
@@ -626,7 +543,7 @@ Figure commands
626
543
inline void suptitle (const std::string &suptitlestr, \
627
544
const std::map<std::string, std::string> &keywords = {})
628
545
629
- .. image :: ../matplotlib_icon.png
546
+ .. image :: ../img/ matplotlib_icon.png
630
547
:align: right
631
548
:width: 20px
632
549
:height: 20px
@@ -642,7 +559,7 @@ Figure commands
642
559
.. cpp :function ::
643
560
inline void axis (const std::string &option)
644
561
645
- .. image :: ../matplotlib_icon.png
562
+ .. image :: ../img/ matplotlib_icon.png
646
563
:align: right
647
564
:width: 20px
648
565
:height: 20px
0 commit comments