You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for pointing me to function curves. They escaped my initial perusal.
But I don't think that answers my question, which is:
how to use two columns to identify a data set.
In my case, the binomial distribution function is a value of k with both p and n as parameters. The plot image link contains three curves, for three combinations of p and n: 0.5 & 20, 0.7 & 20, and 0.5 & 40.
In my dataframe I have two columns, one for p, one for n. I can combine them as a string, into a p&k column and use it for the :color parameter of geom:point Or is there a built-in mechanism to do that?
I took the path of trying this with ggplot, and IMO the most practical solution, both there and in lisp-stat is the one that you came up with: add a column with the color mapping. The important parts to remember here are:
Keywords vs. strings for :color. A keyword like :color :group maps a data column to color and gives you a legend. A string like :color "teal" paints every point one color.
One field per channel. :color takes a single field, just like aes(colour = ...) in ggplot2. So the answer to the issue is the same as in R: make one column that combines p and n, and map :color to it.
You could probably do this with layers too, but I tend to take the shortest route possible with plots, and that's going to be a column with color encoding.
I thought about it more on my end, and realized I need to do a bit more thinking.
Based on my recollection of Wilkinson's Grammar of Graphics (I need to dig out that book),
Legend is just another axis, in addition to x & y.
If that is so, it does not make sense to combine to variables (n & p) as another column, just as it would not make sense to combine to variables into x and then plot y vs that new x.
After implementing the straightforward approach, I will go to Wilkinson's book and look through it.
I looked at Leland Wilkinson's Grammar of Graphics, and in Chapter 12 the second plot includes two legends. In retrospect it is obvious how to do it with my problem. Use two attributes to render a point
Use point shape (circle, square, ...) for one dimension (p)
Use point color for the other dimension (n).
And that is what I did. I defined geom:point rendering baswed on color and shape (I guessed that :shape is a valid keyword, which it is):
Activity
snunez1 commentedon Sep 23, 2026
I think that's close. I suggest using the gamma plot as a framework and then overlaying the ggplot style stuff:
https://lisp-stat.dev/docs/manuals/distributions/ (bottom of page)
Once that works you should be able to replace the mark points with a geom points spec. Also see:
https://lisp-stat.dev/docs/cookbooks/quick-plot/#function-curves
mirkov commentedon Sep 25, 2026
Thank you for pointing me to function curves. They escaped my initial perusal.
But I don't think that answers my question, which is:
In my case, the binomial distribution function is a value of k with both p and n as parameters. The plot image link contains three curves, for three combinations of p and n: 0.5 & 20, 0.7 & 20, and 0.5 & 40.
In my dataframe I have two columns, one for p, one for n. I can combine them as a string, into a p&k column and use it for the
:colorparameter ofgeom:pointOr is there a built-in mechanism to do that?snunez1 commentedon Sep 27, 2026
I took the path of trying this with ggplot, and IMO the most practical solution, both there and in lisp-stat is the one that you came up with: add a column with the color mapping. The important parts to remember here are:
You could probably do this with layers too, but I tend to take the shortest route possible with plots, and that's going to be a column with color encoding.
mirkov commentedon Sep 27, 2026
I will try to implement that.
I thought about it more on my end, and realized I need to do a bit more thinking.
Based on my recollection of Wilkinson's Grammar of Graphics (I need to dig out that book),
If that is so, it does not make sense to combine to variables (n & p) as another column, just as it would not make sense to combine to variables into x and then plot y vs that new x.
After implementing the straightforward approach, I will go to Wilkinson's book and look through it.
mirkov commentedon Sep 30, 2026
I looked at Leland Wilkinson's Grammar of Graphics, and in Chapter 12 the second plot includes two legends. In retrospect it is obvious how to do it with my problem. Use two attributes to render a point
And that is what I did. I defined
geom:pointrendering baswed on color and shape (I guessed that:shapeis a valid keyword, which it is):Works!