ObjectProfile / Roassal3

The Roassal Visualization Engine
MIT License
97 stars 52 forks source link

[Roassal3-Matplotlib] Configuring the plot #105

Open olekscode opened 4 years ago

olekscode commented 4 years ago

From a user perspective, it is very important to configure things such as:

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)

ScatterRed

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

Scatter

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

ScatterRadius

This can also be done with Matplotlib (but it's less pretty):

plt.scatter(sepal_length, petal_length, c='red')

PyScatterRed

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

PyScatter

# 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)

PyScatterRadius

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.
akevalion commented 11 months ago

Moved to pharo-graphics/Roassal