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

  • Home
  • SEARCH
  • 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 1053491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:15:43+00:00 2026-05-16T17:15:43+00:00

I have generated the following plot using the R code that follows it: ggplot(lengths,

  • 0

I have generated the following plot using the R code that follows it:
alt text

ggplot(lengths, aes(length, fill = library)) + geom_density(alpha = 0.2) + coord_cartesian(xlim = c(0, 60000)) 

Now I would like to make the plot a bit prettier:

  1. Make the x-axis show length every
    5000 units (instead of every 20000)
  2. Add x-values on top of the three
    peaks (approx 3000,5000 and 35000).

How can I do that?

update
in response to James:
alt text

  • 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-05-16T17:15:44+00:00Added an answer on May 16, 2026 at 5:15 pm

    How about:

    (first create a reproducible example)

    set.seed(1001)
    lengths <- data.frame(length=c(rgamma(1000,shape=10,scale=500),
                        10000+rgamma(1000,shape=5,scale=700),
                        rnorm(500,mean=30000,sd=2000)),
                      library=factor(rep(2:1,c(2000,500))))
    

    (cute stuff to find peak locations and heights)

    peakfun <- function(x) {
      d <- density(x$length)
      peaks <- which(diff(sign(diff(d$y)))==-2)
      data.frame(x=d$x[peaks],y=d$y[peaks])
    }
    
    peakdat <- ddply(lengths,.(library),peakfun)
    peakdat <- peakdat[-1,] ## drop spurious peak
    

    (draw the plot)

    library(ggplot2)
    ggplot(lengths, aes(length, fill = library)) +
      geom_density(alpha = 0.2) +
      scale_x_continuous(limits = c(0,60000),
                         breaks = seq(0,60000,by=5000))+
      geom_text(data=peakdat,aes(x=x,y=y,label=round(x)),vjust=1)
    

    you probably want to tweak the vertical height of the labels a little

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

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Keep it simple, don't overdesign. Start with calling it directly… May 17, 2026 at 2:08 am
  • Editorial Team
    Editorial Team added an answer I just stumbled upon your question and was sad to… May 17, 2026 at 2:08 am
  • Editorial Team
    Editorial Team added an answer Yes there are a couple of tools for to do… May 17, 2026 at 2:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following code generated dynamically. It can be just one, two, three
I have some surface data that is generated by an external program as XYZ
From the documentation for ggplot2's geom_tile() function, we have the following simple plot: #
I have generated the following regular expression in a project I am working on,
In .NET I have generated the following public key file: <RSAKeyValue> <Modulus>xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBECzRxiCWCHm1KEg59LUD3fxTG5ogGiNxDj9wSguCIzFdUxBYq5ot2J4iLgGu0qShml5vwk=</Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue>
I have the following Code to display Data from the Database in XML Document
I have the following dynamically generated array: var myArray = (0% { left:74px; top:202px;
I have digging through the C# code generated by SWIG for Quantlib and came
I'm wondering if the following is possible. I have a survey with 100+ questions,
Sorry i could not find a proper title to this question. I have generated

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.