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 8376373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:25:05+00:00 2026-06-09T15:25:05+00:00

I am visualizing a panel dataset with geom_point where y = var1 , x

  • 0

I am visualizing a panel dataset with geom_point where y = var1, x = year, and color = var2. The problem is that there are many overlapping points, even with horizontal jitter.

Reducing the point size or setting a low alpha value is undesirable because both reduce the visual impact of the second variable, which has a very long right skew. I would like ggplot to place the points with the highest values of var2 on top of all other overlapping points.

Reproducible example:

df <- data.frame(diamonds)

ggplot(data = df,aes(x=factor(cut),y=carat,colour=price)) + 
  geom_point(position=position_jitter(width=.4))+
  scale_colour_gradientn(colours=c("grey20","orange","orange3"))

How does one place the points with highest values in df$price on top of an overlapping stack of points?

  • 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-09T15:25:06+00:00Added an answer on June 9, 2026 at 3:25 pm

    It looks as though grid plots in the order of the data,

    library(grid)
    
    d <- data.frame(x=c(0.5,0.52),y=c(0.6,0.6), fill=c("blue","red"),
                    stringsAsFactors=FALSE)
    
    grid.newpage()
    with(d,grid.points(x,y,def='npc', pch=21,gp=gpar(cex=5, fill=fill)))
    with(d[c(2,1),], grid.points(x,y-0.2,def='npc', pch=21,
                                 gp=gpar(cex=5, fill=fill)))
    

    so I would suggest you first reorder your data.frame, and pray that ggplot2 won’t mess with it 🙂

    library(ggplot2)
    library(plyr)
    df <- diamonds[order(diamonds$price, decreasing=TRUE), ]
    # alternative with plyr
    df <- arrange(diamonds, desc(price))
    last_plot() %+% df
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first a picture for visualizing the problem As you can see, there is a
There are not very many options for a virtualizing wrap panel for use in
Is there any lib for visualizing large social networks? Moreover, does it make sense
Is there a tool out there for visualizing dynamic call graphs? I saw a
Is there a tool for visualizing a given java3d app's scenegraph? Just like there
I'm having trouble visualizing the end product of this problem: Define a class called
Does anyone know a free framework for visualizing decision trees that allows the use
Is there a good C# library for drawing/visualizing graphs? I'm talking about node-path visualization
I'm working on visualizing a matrix in R (almost exactly like http://reference.wolfram.com/mathematica/ref/MatrixPlot.html ), and
I have a project for visualizing some data on tablet. I'll probably use android

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.