Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:26:09+00:00 2026-06-08T17:26:09+00:00

Users, I’d like to have some tips for a ternaryplot (vcd). I have this

  • 0

Users, I’d like to have some tips for a ternaryplot (“vcd”).

I have this dataframe:

a <- c(0.1, 0.5, 0.5, 0.6, 0.2, 0, 0, 0.004166667, 0.45) 
b <- c(0.75,0.5,0,0.1,0.2,0.951612903,0.918103448,0.7875,0.45)
c <- c(0.15,0,0.5,0.3,0.6,0.048387097,0.081896552,0.208333333,0.1) 
d <- c(500,2324.90,2551.44,1244.50, 551.22,-644.20,-377.17,-100, 2493.04) 
df <- data.frame(a, b, c, d)

and I’m building a ternary plot:

ternaryplot(df[,1:3], df$d)

How can I map the continuous variable d, obtaining a result similar to this one?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:26:10+00:00Added an answer on June 8, 2026 at 5:26 pm

    This is probably not the most elegant way to do this but it works (from scratch and without using ternaryplot though: I couldn’t figure out how to do it).

    a<- c (0.1, 0.5, 0.5, 0.6, 0.2, 0, 0, 0.004166667, 0.45) 
    b<- c (0.75,0.5,0,0.1,0.2,0.951612903,0.918103448,0.7875,0.45)
    c<- c (0.15,0,0.5,0.3,0.6,0.048387097,0.081896552,0.208333333,0.1) 
    d<- c (500,2324.90,2551.44,1244.50, 551.22,-644.20,-377.17,-100, 2493.04) 
    df<- data.frame (a, b, c)
    
    
    # First create the limit of the ternary plot:
    plot(NA,NA,xlim=c(0,1),ylim=c(0,sqrt(3)/2),asp=1,bty="n",axes=F,xlab="",ylab="")
    segments(0,0,0.5,sqrt(3)/2)
    segments(0.5,sqrt(3)/2,1,0)
    segments(1,0,0,0)
    text(0.5,(sqrt(3)/2),"c", pos=3)
    text(0,0,"a", pos=1)
    text(1,0,"b", pos=1)
    
    # The biggest difficulty in the making of a ternary plot is to transform triangular coordinates into cartesian coordinates, here is a small function to do so:
    tern2cart <- function(coord){
        coord[1]->x
        coord[2]->y
        coord[3]->z
        x+y+z -> tot
        x/tot -> x  # First normalize the values of x, y and z
        y/tot -> y
        z/tot -> z
        (2*y + z)/(2*(x+y+z)) -> x1 # Then transform into cartesian coordinates
        sqrt(3)*z/(2*(x+y+z)) -> y1
        return(c(x1,y1))
        }
    
    # Apply this equation to each set of coordinates
    t(apply(df,1,tern2cart)) -> tern
    
    # Intrapolate the value to create the contour plot
    resolution <- 0.001
    require(akima)
    interp(tern[,1],tern[,2],z=d, xo=seq(0,1,by=resolution), yo=seq(0,1,by=resolution)) -> tern.grid
    
    # And then plot:
    image(tern.grid,breaks=c(-1000,0,500,1000,1500,2000,3000),col=rev(heat.colors(6)),add=T)
    contour(tern.grid,levels=c(-1000,0,500,1000,1500,2000,3000),add=T)
    points(tern,pch=19)
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Users can access others users profiles like this: site.com/username My find method in my
Users of my application have the possibility of choosing some values from list. The
Users writing an article have the option to write some tags, tags are written
Users will be able to write some documents. Those documents will consists of chapters
Users have subscriptions to feeds but when I change (as suggested elsewhere on stackO)
Users drag rows up and down in my DataGridView. I have the dragging logic
Users can easily rename special folders like Computer, Network etc. to whatever they like.
Users are uploading fotos to our php build system. Some of them we are
users table In the Registration time every user have to put parent_id , who

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.