Vindaar / ggplotnim

A port of ggplot2 for Nim
https://vindaar.github.io/ggplotnim
MIT License
177 stars 15 forks source link

make `aes` a macro with untyped & factor support #82

Closed Vindaar closed 4 years ago

Vindaar commented 4 years ago

Mainly this PR turns aes into a macro.

First of all the functionality of before remains fully unchanged. In addition to that however, the following two things are now possible:

aes(x, y, color = class) == aes("x", "y", color = "class")

which holds, if there are no variables / procs declared with the identifiers given as arguments. Both named and unnamed arguments are of course allowed.

Another new addition is support for factor. This forces the associated scale to be interpreted as discrete. For x and y scales this was previously possible using scale_x/y_discrete, but no such thing was possible for e.g. a color scale.

aes(x, y, color = factor(class))

Even if class does not actually satisfy the condition for a discrete scale, it will be interpreted as such. Of course this can result in really ugly plots if abused. :)