Skip to content

Instantly share code, notes, and snippets.

@aviatesk aviatesk/linqplot.jl

Created Apr 22, 2020
Embed
What would you like to do?
plotting `@linq` chain
using DataFrames, DataFramesMeta, Plots, StatsPlots, StatsBase
# HACK:
# integrate StatsPlots.@df into @linq chain in a way data frame keeps to be passed even after plot
# but, the `names` part might be too dangerous
for n in names(StatsPlots)
function DataFramesMeta.linq(::DataFramesMeta.SymbolParameter{n}, d, args...)
plotcall = Expr(:call, n, args...)
return quote let d = $d
display(@df d $plotcall)
d
end end
end
end
@linq DataFrame(name = rand('A':'Z', 1000), val = rand(1000)) |>
by(:name, mean = mean(:val)) |>
sort(:name) |>
bar(:name, :mean; orientation = :horizontal) |>
transform(meanall = fill(mean(:mean), length(:mean))) |>
vline!(:meanall)
@aviatesk

This comment has been minimized.

Copy link
Owner Author

aviatesk commented Apr 22, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.