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

Density force the same xaxis on wide data plots with multiple variable #479

Closed
DarioSarra opened this issue Nov 23, 2023 · 1 comment
Closed

Comments

@DarioSarra
Copy link

I am trying to have a figure with the density plots of a variable and its log10 transform next to each other. I tried to pass the two variables as a string vector and call col = dims(1). I obtain the plot, but the x-axis's span is the same for both plots, even if they have very different min and max values. I was expecting the two plots to have independent x-axis spans. I tried using facet=(; linkxaxes=:none,), but it doesn't affect the result. It seems that the density was calculated taking the extrema from a combination of the 2 variables.

Here is an example:

v1 = rand(120)
v2 = log10.(v1)
testdf = DataFrame(v1 = v1,v2 = v2,cat = rand(["a","b","c"],120))
xvars = ["v1", "v2"]
plt = data(testdf) * AlgebraOfGraphics.density() * mapping(xvars, color = "cat", col = dims(1))
draw(plt, facet=(; linkxaxes=:none,))

density_example

@jkrumbiegel
Copy link
Member

You can pass datalimits = extrema to density to avoid this:

v1 = rand(120)
v2 = log10.(v1)
testdf = DataFrame(v1 = v1,v2 = v2,cat = rand(["a","b","c"],120))
xvars = ["v1", "v2"]
plt = data(testdf) * AlgebraOfGraphics.density(datalimits = extrema) * mapping(xvars, color = "cat", col = dims(1))
draw(plt, facet=(; linkxaxes=:none,))
image

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

No branches or pull requests

2 participants