Replies: 4 comments 9 replies
-
How does your proposal relate to the existing struct-based ln := plots.NewLine(x, y)
ln.Line.SetWidth(2).SetColor(colors.Red)
ln.Point.SetSize(4)
plt.Add(ln) I think that proposal is better, but still much less concise than matplotlib. |
Beta Was this translation helpful? Give feedback.
-
Some possible additional requirements,
Please excuse me if you already support some of the above. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Here's the current plan, getting implemented -- input much appreciated! https://github.com/cogentcore/core/tree/goal/plot |
Beta Was this translation helpful? Give feedback.
-
Some considerations,
|
Beta Was this translation helpful? Give feedback.
-
This thread is to define the Plot API, for the
goal
/ math / data system.The classic issues apply here: imperative, code-based vs. declarative; tab completion for parameters, etc. In general the guiding principle is that closures setting
struct
based parameter state provide the best overall solution. The current practice often falls to string-based metadata -- won't be hard to improve on that!The relevant standard for what people likely already know is matplotlib: https://matplotlib.org/stable/plot_types/index.html
plt.plot(x, y)
whereplt
is the package import path.plt.show()
generates the plot (where does it even go?)plot
,scatter
,bar
) and presumably a mix of shared and unique parameters for each plot type.Overall, there are 2 major categories of usage:
tensor
data, for a specific analysis, often from an interactive REPL session where you are exploring different things, and also for final publication-quality plots with multiple sub-plots etc.table
of data with lots of data columns (variables), per the standard emergent sims. In the sims, we want to provide parameters for different variables (ranges, display params) and overall plot params, while also allowing users to select what to look at etc. This overall requires a declarative, struct of params solution.The existing
plot
base api, copied from thegonum
package, looks like this:and if you want to parameterize things, you do it with properties on the elements:
with shared
Style
elements likeLineStyle
,PointStyle
,TextStyle
etc used throughout.Here's a plausible code-based approach with setter functions:
The tricky issue here is that the properties are organized by sub-structs, which makes it impossible to chain across multiple such elements. Could have global setters that would have to be redundantly defined to chain across sub-structs.
A styler closer could be used instead:
And a
Style(func(ln *plots.Line))
would also be available for closure-based styling:Beta Was this translation helpful? Give feedback.
All reactions