Roassal3
Roassal3 copied to clipboard
[Roassal3-Matplotlib] Configuring the plot
From a user perspective, it is very important to configure things such as:
- Plot size (min and max x and y)
- Number of ticks (size of the grid)
- Colors (of lines, points, fills etc.)
- Shapes of points (round, square, triangle, etc.)
- Style of lines (solid, dashed, dotted, etc.)
- Sizes of things (radius of points width of lines)
Besides, these things should be easy to configure for a whole plot: "make all points red" and as a function of some parameter: "select different colors for points based on Sex categorical variable" or "make radius of points dependent on the GDP variable".
Here is an example of how this works in ggplot:
ggplot(data = iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_point(color = red)

ggplot(data = iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_point(aes(color = Species))

ggplot(data = iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_point(aes(color=Species, size = Sepal.Width))

This can also be done with Matplotlib (but it's less pretty):
plt.scatter(sepal_length, petal_length, c='red')

plt.scatter(sepal_length, petal_length, c=species)

# scale sepal_width to the range [10, 50] to get the desired radii of points
w = sepal_width
sizes = (w - w.min()) / (w.max() - w.min()) * (50-10) + 10
plt.scatter(sepal_length, petal_length, c=species, s=sizes)

In Pharo, we could have something like this:
points := RSScatter new
x: sepalLength
y: petalLength.
points color: Color red.
points color: aBlock.
points colorBasedOn: species.
points size: 20.
points size: aBlock.
points sizeBasedOn: sepalWidth.
Moved to pharo-graphics/Roassal