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

How to add axis labels and change marker shape for each group #19

Closed
itsdfish opened this issue Jul 5, 2024 · 2 comments
Closed

How to add axis labels and change marker shape for each group #19

itsdfish opened this issue Jul 5, 2024 · 2 comments

Comments

@itsdfish
Copy link

itsdfish commented Jul 5, 2024

Hello,

Thank you for putting together this package. I would like to plot a 3-simplex in a ternary diagram where the fourth dimension represented by a color gradient. I encountered problems adding axis labels and representing two groups of data with different marker shapes. I was wondering if you might provide some guidance. Here is a MWE:

using Makie 
using GLMakie 
using TernaryDiagrams
using Distributions
using ColorSchemes 

fig = Figure();
ax = Axis(fig[1, 1]);

ternaryaxis!(ax; labelx = "1", labely = "2", labelz = "3");

data1 = rand(Dirichlet([5,1,1,10]), 10)'
data2 = rand(Dirichlet([1,5,1,1]), 10)'
ternaryscatter!(
    ax,
    data1[:,1],
    data1[:,2],
    data1[:,3],
    color = [get(ColorSchemes.Spectral, w, extrema(data1[:,4])) for w in data1[:,4]],
    marker = :circle,
    markersize = 20
)

ternaryscatter!(
    ax,
    data2[:,1],
    data2[:,2],
    data2[:,3],
    color = [get(ColorSchemes.Spectral, w, extrema(data2[:,4])) for w in data2[:,4]],
    marker = :triangle,
    markersize = 20
)
fig

Thank you in advance.

@thomvet
Copy link
Contributor

thomvet commented Sep 27, 2024

What was the issue? The below code seems to produce a sensible image (slight adaptations from your code):

using GLMakie 
using TernaryDiagrams
using Distributions
using ColorSchemes 

fig = Figure();
ax = Axis(fig[1, 1]);

ternaryaxis!(ax; labelx = "1", labely = "2", labelz = "3");

data1 = rand(Dirichlet([5,1,1,10]), 10)'
data2 = rand(Dirichlet([1,5,1,1]), 10)'
ternaryscatter!(
    ax,
    data1[:,1],
    data1[:,2],
    data1[:,3],
    color = [get(ColorSchemes.Reds, w, extrema(data1[:,4])) for w in data1[:,4]],
    marker = :circle,
    markersize = 20
)

ternaryscatter!(
    ax,
    data2[:,1],
    data2[:,2],
    data2[:,3],
    color = [get(ColorSchemes.Blues, w, extrema(data2[:,4])) for w in data2[:,4]],
    marker = :utriangle,
    markersize = 20
)

xlims!(ax, -0.2, 1.2) # to center the triangle and allow space for the labels
ylims!(ax, -0.3, 1.1)
hidedecorations!(ax) # to hide the axis decorations

fig

image

@itsdfish
Copy link
Author

Great. Thank you for your help!

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