Closed vwkd closed 6 months ago
If you want a “marks-first” approach, you can try Plot.marks
.
Plot.marks(
Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight"})),
Plot.ruleY([0])
).plot({
grid: true
})
Notebook: https://observablehq.com/d/a7a01e1a50b08c73
I don’t think we should overload Plot.plot
to take an array of marks, though.
I meant to also say thank you for sharing your feedback and suggestion. Thank you!
Marks seem to be the only concept that are explicitly named by the
marks
option inPlot.plot
. Other concepts like channels, scales, transforms, etc. seem to not be named directly and instead are implicit in the options for the thing they apply to, e.g.x
andcolor
for scale.Since there can be multiple marks, it makes sense to nest an array in some
marks
option. Maybe it’s also helpful for education to draw attention to the difference between modular marks and fixed charts.To me it had the opposite effect though. Being confronted heads-on with this unknown “marks” concept felt inhibiting. Instead of feeling comfortable to learn the API by experimenting with it, I felt the need to having to study first what these new concepts even mean.
Marks seem to be the most fundamental arguments to a plot. A plot doesn’t do much without a mark, while the other options have sane defaults. It seems unintuitive to nest the most important thing three levels deep, while other optional things go a level higher.
Suggestion: Why not make marks a top-level argument to
Plot.plot
?For example, the marks array could be the first argument, with the rest of the options bag going second.
I believe this could help make Observable Plot more approachable, by not confronting the reader with the new “marks” concept heads-on similar to other concepts like scales.