Needless to say that PLT is not a very good class name. I can propose to rename it to RSPlot.
As for PLTPlot and PLTScatter, I would call them RSLinePlot and RSScatterPlot or RSLine and RSScatter (if possible).
Because it is a bit confusing to create a plot and add a plot to it.
plot := PLT new.
p := PLTPlot new.
plot addPlot: p.
But consider this: you create a plot and add a line to it:
This could be a nice API for drawing multiple things on one plot:
RSPlot new
add: (RSScatterPlot new x: age y: salary)
add: (RSLinePlot new x: age y: age * slope + intercept).
It is still a bit confusing to add ScatterPlot and LinePlot to Plot, so maybe we can take some inspiration from The Grammar of Graphics that was implemented as ggplot
Here are some examples of how we do things with ggplot:
library(ggplot2)
Scatterplot of sepal and petal length of iris flowers with 3 colors denoting classes (species) of flowers: setosa, versicolor, and virginica (the one that I built with Roassal3 and posted on Discord):
I strongly do not recommend making a dependency on DataFrame, but we can take inspiration for the names. For example, RSLineGeometry and RSPointGeometry (or RSScatterGeometry):
Needless to say that
PLT
is not a very good class name. I can propose to rename it toRSPlot
. As forPLTPlot
andPLTScatter
, I would call themRSLinePlot
andRSScatterPlot
orRSLine
andRSScatter
(if possible).Because it is a bit confusing to create a plot and add a plot to it.
But consider this: you create a plot and add a line to it:
Or draw line on a plot:
This could be a nice API for drawing multiple things on one plot:
It is still a bit confusing to add ScatterPlot and LinePlot to Plot, so maybe we can take some inspiration from The Grammar of Graphics that was implemented as ggplot
Here are some examples of how we do things with ggplot:
Scatterplot of sepal and petal length of iris flowers with 3 colors denoting classes (species) of flowers: setosa, versicolor, and virginica (the one that I built with Roassal3 and posted on Discord):
Or the same thing with a regression line and a light theme:
I strongly do not recommend making a dependency on DataFrame, but we can take inspiration for the names. For example,
RSLineGeometry
andRSPointGeometry
(orRSScatterGeometry
):I'm not sure if this is a good API, but I think that we can learn a lot from The Grammar of Graphics, and it seems like the right thing for Pharo