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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:34:09+00:00 2026-06-02T17:34:09+00:00

I have following data and plot: pos <- rep(1:2000, 20) xv =c(rep(1:20, each =

  • 0

I have following data and plot:

pos <- rep(1:2000, 20)
xv =c(rep(1:20, each = 2000))
# colrs <- unique(xv)
colrs <- xv # edits 
yv =rnorm(2000*20, 0.5, 0.1)

xv   = lapply(unique(xv), function(x) pos[xv==x])
to.add = cumsum(sapply(xv, max) + 1000)

bp <- c(xv[[1]], unlist(lapply(2:length(xv), function(x) xv[[x]] + to.add[x-1])))
plot (bp,yv, pch = "*", col = colrs)

enter image description here

I have few issues in this plot I could not figure out.

(1) I want to use different color for different group or two different color for different groups (i.e xv), but when I tried color function in terms to be beautiful mixture. Although I need to highlight some points (for example bp 4000 to 4500 for example with blue color)

(2) Instead of bp positions I want to put a tick mark and label with the group.

Thank you, appreciate your help.

Edits: with help of the following answer (with slight different approach in case I have unbalanced number in each group will work) I could get the similar plot. But still question remaining regarding colors is what if I want to use two alternate colors in alternate group ?

  • 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-02T17:34:10+00:00Added an answer on June 2, 2026 at 5:34 pm

    You can solve your colour issue by repeating the colour index however many times each group has a point plotted, like so:

    plot (bp,yv, pch = "*", col = rep(colrs,each=2000))
    

    The default colour palette (see ?palette or palette() ) will wrap around itself and you might want to specify your own to get 20 distinct colours.

    To relabel the x axis, try plotting without the axis and then specifying the points and labels manually.

    plot (bp,yv, pch = "*", col = rep(colrs,each=2000),xaxt="n")
    axis(1,at=seq(1000,58000,3000),labels=1:20)
    

    If you are trying to squeeze a lot of labels in there, you might have to shrink the text (cex.axis)or spin the labels 90 degrees (las=2).

    plot (bp,yv, pch = "*", col = rep(colrs,each=2000),xaxt="n")
    axis(1,at=seq(1000,58000,3000),labels=1:20,cex.axis=0.7,las=2)
    

    Result:

    enter image description here

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

Sidebar

Related Questions

All right, let's say I have the following plot. df = data.frame(date=c(rep(2008:2013, by=1)), value=c(303,407,538,696,881,1094))
I have the following data set that I am trying to plot with ggplot2,
From the documentation for ggplot2's geom_tile() function, we have the following simple plot: #
I have the following function, which I would like to plot using ggplot: f(x)
I have the following plot: library(ggplot2) ib<- data.frame( category = factor(c(Cat1,Cat2,Cat1, Cat1, Cat2,Cat1,Cat1, Cat2,Cat2)),
Possible Duplicate: Automatically plot different colored lines in MATLAB I have the following data
I have the following density plot: My input data looks as follows: PA <-
I have the following problem when trying to plot some 3D data in Mathematica.
I have to plot data which is in the following format : x =
I have following data to save in database using php my data is :

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.