JuliaData / TypedTables.jl

Simple, fast, column-based storage for data analysis in Julia
Other
145 stars 25 forks source link

add Plots.jl recipes #94

Open BeastyBlacksmith opened 2 years ago

BeastyBlacksmith commented 2 years ago

This adds two recipes to automatically set the labels.

using TypedTables, Plots
tt = Table(a=[1,2,3], b=[4,3,6], c=[0.2,2.0,5.4])
plot(tt)

gives takes first column as x and second column as y. Then you can use either of

plot(tt; indices = [2,3])
plot(tt, (:a, :c))

to get other combinations.

Currently this only works for Tables, but with a common supertype this could potentially be extended to more TypedTables.

andyferris commented 2 years ago

Out of curiosity… should this be done for the Tables.jl interface in general?

BeastyBlacksmith commented 2 years ago

Might be useful, if that is feasible, but I don't know the interface very well to judge that

quinnj commented 2 years ago

Seems to me like it could work on generic Tables.jl given what is defined here; I don't know RecipesBase.jl well enough to know what kind of dependency it is, but we could look into adding this to Tables.jl directly.

andyferris commented 2 years ago

I don't know RecipesBase.jl well enough to know what kind of dependency it is

It seems to be a single ~500-line file. Like Tables.jl it's mostly there to provide the interface to be imported and extended, so I suspect there's some synergy. Does DataFrames already have the equivalent of this PR?

BeastyBlacksmith commented 2 years ago

Does DataFrames already have the equivalent of this PR?

I didn't make any other PRs. StatsPlots.jl has a @df macro that can be used to extract columns at the call site, that is scheduled to be moved to Plots.jl for 2.0 (no timeframe though).

I'll also note that DimensionalData.jl provides a set of more elaborate recipes, but I tried to keep things minimalistic here.