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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:22:46+00:00 2026-06-06T17:22:46+00:00

I am trying to make a plot in R that has a portion of

  • 0

I am trying to make a plot in R that has a portion of the plot grey to emphasize this area. Unlike other examples, I don’t want to color an area under a plot, but instead color an area on a plot starting at one area and going to the end of the graph. When I try to use rect() or polygon() it obscures the plots I want to emphasize.

For example:

x_mean <- c(1, 2, 3, 4)
y_mean <- c(1, 1, 1, 1)

y_max <- c(4, 4, 4, 4)
y_min <- c(-4, -4, -4, -4)


x_shade <- c(2, 3, 4)

y_max_shade <- c(4, 4, 4)
y_min_shade <- c(-4, -4, -4)

plot(x=rep(x_mean, 3), y=c(y_mean, y_max, y_min), bty='n', type="n" )
arrows(x0=x_mean, y0=y_min, x1=x_mean, y1=y_max, length=0)
points( x=x_mean, y=y_mean, pch=16)

This will plot 4 lines on the graph. How do I draw a grey box in the background from the 2nd line to the end of the plot?

  • 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-06T17:22:48+00:00Added an answer on June 6, 2026 at 5:22 pm

    Just so that you’re left with more than just a comment, here’s a possible solution:

    plot(x=rep(x_mean, 3), y=c(y_mean, y_max, y_min), bty='n', type="n" )
    rect(2,-4,4,4,col = rgb(0.5,0.5,0.5,1/4))
    arrows(x0=x_mean, y0=y_min, x1=x_mean, y1=y_max, length=0)
    points( x=x_mean, y=y_mean, pch=16)
    

    enter image description here

    Note that I also demonstrated how to use alpha blending in the color specification (using rgb). This can also be useful for this sort of thing. Try moving the rect line to the end, and notice that the results still look ok, because the fill color is partially transparent.

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

Sidebar

Related Questions

I'm trying make an entity with doctrine that has three associations with other entities
I am trying to make a bar plot that has extra data on it.
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to create a plot using pyplot that has a discontinuous x-axis. The
This equation leads from my previous question . I want to plot dots that
I am trying to make a faceted plot in ggplot2 of the coefficients on
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I'm trying to make a histogram in [R], and the normal curve that describes
I'm (trying to) using JSON with PHP. I want to plot a graph using
I am trying to make a user generated nav bar. This nav bar because

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.