Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alpha for grouping #452

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Use alpha for grouping #452

wants to merge 1 commit into from

Conversation

greimel
Copy link
Collaborator

@greimel greimel commented Mar 31, 2023

Example 1: BarPlot

image

bar_df = DataFrame(
	x = ["a", "a", "a", "b", "b"],
	y = [1, 1, 1, 1, 1],
	grp2 = "h" .* string.([1, 2, 1, 2, 1]),
	grp = "g" .* string.(1:5)
)

data(bar_df) * mapping(:x, :y, stack=:grp, color=:x, alpha=:grp2) * visual(BarPlot) |> draw

Example 2: Scatter

image

n = 300
df = DataFrame(
	x = rand(n), 
	y = rand(n), 
	grp = rand(["a", "b", "c"], n),
	grp2 = rand(["x", "y", "z"], n),
	grp3 = rand(["l", "m", "n"], n)
)

data(df) * mapping(:x, :y, alpha = :grp, color=:grp2, layout=:grp3) * visual(Scatter) |> draw

Example 3: Lines

image

lines_df = let
	T = 100
	t = Int[]
	x = Float64[]
	grp1 = String[]
	grp2 = String[]
	grp3 = String[]

	grps = ["a", "b", "c"]
	
	for i  1:length(grps)
		for j  1:length(grps)
			for k  1:length(grps)
				append!(t, 1:T)
				append!(x, cumsum(randn(T)))
				append!(grp1, fill("1" * grps[i], T))
				append!(grp2, fill("2" * grps[j], T))
				append!(grp3, fill("3" * grps[k], T))
			end
		end
	end

	DataFrame(; t, x, grp1, grp2, grp3)
end

data(lines_df) * mapping(:t, :x, alpha = :grp1, color=:grp2, layout=:grp3) * visual(Lines) |> draw

@jonas-schulze
Copy link

This would be very handy when highlighting a subset of points in a slide show. I'm looking forward to this! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants