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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:18:41+00:00 2026-06-12T04:18:41+00:00

I have a dataset that contains observations for every second of four consecutive days

  • 0

I have a dataset that contains observations for every second of four consecutive days (roughly 340’000 data points). This is too much to display in a scatter plot. I would like to plot only a uniform sample of, say, 2000 time points.

Is it possible to achieve this with ggplot2‘s “grammar of graphics” approach? I haven’t found any built-in “sampling” modifier, but perhaps it’s easy enough to write one?

library(ggplot2)

x <- 1:100000
d <- data.frame(x=x, y=rnorm(length(x)))
ggplot(d[sample(x, 2000), ], aes(x=x, y=y)) + geom_point()

This is how it can be “hacked” by modifying the data passed to ggplot. But I don’t want to modify the data, just filter it to include only a sample.

ggplot(d, aes(x=x, y=y)) + ??? + geom_point()

EDIT: I’m specifically looking for sampling, not smoothing or binning. The data I have shows the time it takes to simulate one second of a specific process. The simulation has been parallelized, and for each simulated seconds I have the run times for each of the cores involved (8 in total). I want to show sub-optimal load balancing by plotting just the raw data points. The reason for the sampling is just that 300’000 data points are way too much for a scatter plot: Plotting takes too long and the visualization is no good.

  • 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-12T04:18:43+00:00Added an answer on June 12, 2026 at 4:18 am

    You can subset with in the geom_point call using the data argument:

    ... + geom_point(data=d[sample(x,2000),])
    

    This way, you are free to add other geoms using all the data, eg, using the example data:

    ggplot(d, aes(x=x, y=y)) + geom_hex() + geom_point(data=d[sample(x,2000),])
    

    hexbin and sampled points

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

Sidebar

Related Questions

I have generated a dataset that contains data spanning thirty days. Im trying to
I have a DataSet named dsView that contains data. Here is the code i
I have a (dense) dataset that consist of 5 groups, so my data.frame looks
I have a dataset of 1 minute data of 1000 stocks since 1998, that
I have a Dataset that contains tables from a university database, two(actually more) of
I have a table that contains a lot of data, where we particularly care
I have a dataset that contains: Table { date itemName } The date for
I have a web service that returns a dataset object that contains the current
I have a dataset that consists of prices for various rental cars. The data
I have a DataSet that contains a column, call it Type which contains ints.

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.