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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:00:29+00:00 2026-06-17T04:00:29+00:00

I wanted to do something similar to this, but a little more complex. Change

  • 0

I wanted to do something similar to this, but a little more complex.

Change colours of particular bars in a bar chart

Here is my data:

x <- c(3,-1.4,0.8,-0.3,-1.2,-2.5,1.5,-1.4)
breaks <- c(-Inf, -1, 1, Inf)
cols <- c("blue", "grey", "red")[findInterval(x, vec=breaks)]
barplot(x, col = cols, horiz=T)

so this is what it makes:

chart http://www.diabolotricks.net/Rplot-test.jpg

What I want to do is then use the p-value of that change to color the bars that are not statistically significant grey as well.

pval<- c(0.01,0.03,0.04,0.89,0.45,0.01,0.03,0.02)

so the fourth bar would be grey too.

I tried using various combinations of ifelse to no avail.

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

    Just replace the appropriate values in cols. This is done easily with [<- or you could use replace which is a wrapper for the same thing

    Assuming you are using alpha = 0.05

    myalpha <- 0.05
    cols[pval > myalpha] <- 'grey' # could also be cols <- replace(cols, pvals > 0.05, 'grey')
    barplot(x, col = cols, horiz=T)
    

    enter image description here

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

Sidebar

Related Questions

So I have always wanted to do something like this, but never knew how
after reading jquery xml select I wanted to do something similar with this rdf/xml:
Similar to this but more complicated. I need to override all tooltips (and all
I've read through a few questions that address something similar, but wanted to ask
I need to create something similar to a progress bar but which gradually moves
If I wanted to represent states or options or something similar using binary flags
I wanted to write something basic in assembly under Windows. I'm using NASM, but
So I wanted to have something like in this image . Basically you have
If I wanted to do something like this: collection.each do |i| return nil if
Something I've wanted to learn for quite a time now, but haven't been able

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.