How to plot a simple scatter plot using ggplotd

Serg Gini kornburn at yandex.ru
Tue Aug 12 07:18:45 UTC 2025


On Tuesday, 12 August 2025 at 02:23:49 UTC, Marc wrote:
> Hello everyone,
> I am trying to use ggplotd to visualize a data set before and 
> after fitting a linear model. how ever i'm struggling to get it 
> to work with a simple example. I tried the following and i get 
> errors for boths:
>
> ```d
> import mir.ndslice;
> import ggplotd.aes: aes, Aes;
> import ggplotd.axes: xaxisLabel, yaxisLabel;
> import ggplotd.ggplotd: GGPlotD, putIn;
> import ggplotd.geom: geomPoint, geomBox, geomLine;
>
> void main(){
>    auto x = [1.47f, 1.50f, 1.52f].sliced(3);
>    auto y = [52.21f, 53.12f, 54.48f].sliced(3);
>    auto xs = x.array;
>    auto ys = y.array;
>    auto gg = aes!("x", "y")(xs, ys).geomPoint;
>    // or
>    auto gs = aes!("x", "y")(xs, ys).array.geomPoint;
> }
> ```
> I would appreciate any help or advice on getting it to work.

```d
auto gg = xs.zip(ys)
             .map!((t) => aes!("x","y")(t[0], t[1]))
             .geomPoint.putIn(GGPlotD());
```

Some examples can be found here:
https://blackedder.github.io/ggplotd/example.html
https://blackedder.github.io/ggplotd/ggplotd/ggplotd/GGPlotD.html


More information about the Digitalmars-d-learn mailing list