Skip to content

Commit 7222379

Browse files
committed
Merge branch 'master' of github.com:Cryoris/matplotlib-cpp
2 parents 0e32084 + 8843b82 commit 7222379

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main()
4848
// Plot a red dashed line from given x and y data.
4949
plt::plot(x, w,"r--");
5050
// Plot a line whose name will show up as "log(x)" in the legend.
51-
plt::named_plot("log(x)", x, z);
51+
plt::plot(x, z, {{"label", "log(x)"}});
5252
// Set x-axis to interval [0,1000000]
5353
plt::xlim(0, 1000*1000);
5454
// Add graph title
@@ -65,7 +65,7 @@ int main()
6565

6666
![Basic example](./examples/basic.png)
6767

68-
Alternatively, matplotlib-cpp also supports some C++11-powered syntactic sugar:
68+
Also, matplotlib-cpp also supports being given multiple plot commands. However these have to come in triplets of `(x, y, fmt)` where `fmt` is a formatting string, such as `r--`.
6969
```cpp
7070
#include <cmath>
7171
#include "matplotlibcpp.h"
@@ -77,18 +77,18 @@ int main()
7777
{
7878
// Prepare data.
7979
int n = 5000; // number of data points
80-
vector<double> x(n),y(n);
80+
vector<double> x(n), y(n), z(n);
8181
for(int i=0; i<n; ++i) {
8282
double t = 2*M_PI*i/n;
8383
x.at(i) = 16*sin(t)*sin(t)*sin(t);
8484
y.at(i) = 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t);
85+
z.at(i) = 12.5 + abs(sin(x.at(i)));
8586
}
8687

8788
// plot() takes an arbitrary number of (x,y,format)-triples.
8889
// x must be iterable (that is, anything providing begin(x) and end(x)),
8990
// y must either be callable (providing operator() const) or iterable.
90-
plt::plot(x, y, "r-", x, [](double d) { return 12.5+abs(sin(d)); }, "k-");
91-
91+
plt::plot(x, y, "r-", x, z, "k-");
9292

9393
// show plots
9494
plt::show();
@@ -189,6 +189,17 @@ int main()
189189

190190
![surface example](./examples/surface.png)
191191

192+
Eigen support and generic vectors
193+
-------------
194+
195+
This fork of the library supports working not only with `std::vector`s, but with all classes providing the same
196+
member functions as `std::vector`. In particular it is suited to be used with the C++ template library Eigen.
197+
198+
The generalisation is currently a working process. Following functions already support generic vectors:
199+
* `plot`
200+
* `loglog`
201+
* `semilogx` and `semilogy`
202+
192203
Installation
193204
------------
194205

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy