Skip to content

Commit 2f53e46

Browse files
committed
Documents setsize
1 parent 91d2e2f commit 2f53e46

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

docs/ref/visualmodels/graphvisual.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,26 @@ Note that the axis colour is applied to the axis box/cross/L, the axis ticks, ax
328328

329329
### Controlling the size of the axes
330330

331+
The default graph size is 1 x 1 in model units.
332+
You can change this with a call to `setsize()`. This call has to come before any data is set into the graph with `setdata`.
333+
For example, to make a graph that has width 3 and height 2, use `setsize (3, 2)`:
334+
335+
```c++
336+
auto gv = std::make_unique<mplot::GraphVisual<float>> (sm::vec<>{});
337+
gv->set_parent (v.get_id());
338+
339+
// set size before first call to setdata
340+
gv->setsize (3, 2);
341+
342+
gv->setdata (csv_positions, ds);
343+
gv->finalize();
344+
```
345+
346+
Here are the graphs you'd get for `setsize (3, 2)`, `setsize (1, 1)` and `setsize (1.33, 2)`:
347+
348+
![Screenshot of graphs after different setsize calls](https://github.com/sebsjames/mathplot/blob/main/docs/images/graphvisual_setsize.png?raw=true)
349+
350+
331351
### Controlling the data limits
332352
333353
### The fonts

0 commit comments

Comments
 (0)