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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:51:04+00:00 2026-05-16T16:51:04+00:00

In vanilla plotting, it is possible to use a polygon call in the panel.first

  • 0

In vanilla plotting, it is possible to use a polygon call in the panel.first argument to plot to highlight a background region. Is it possible to do the same in ggplot2? Can it be done while preserving the gridlines?

eg:

# plot hp and wt for mtcars data, highlighting region where hp/wt ratio < 35
with(mtcars,plot(hp,wt,
     panel.first=polygon(c(0,0,max(wt)*35),c(0,max(wt),max(wt)),
     col="#d8161688",border=NA)))
  • 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-16T16:51:04+00:00Added an answer on May 16, 2026 at 4:51 pm

    Yes, that’s possible with ggplot2. To preserve the visibility of grid lines you can use alpha transparency. Note that, in general, the order in which geoms and stats are applied matters.

    tmp <- with(mtcars, data.frame(x=c(0, 0, max(wt)*35), y=c(0, max(wt), max(wt))))
    ggplot(mtcars, aes(hp, wt)) + 
      geom_polygon(data=tmp, aes(x, y), fill="#d8161688") + 
      geom_point()
    

    ggplot2 output

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

Sidebar

Related Questions

I am trying to use vanilla forum with proxyconnect and it requires i give
I've got a vanilla .net class library which contains some types which are [ComVisible]
I need to remove all attributes set on certain elements (using vanilla JS or
what is the Technical meaning of this context plain-vanilla Java Beans & plain-vanilla Java
I work for an ISV and we have a vanilla ASP.NET (no mvc) web
I know that unfortunately detecting and changing programmatically data connection (GPRS/UMTS) on vanilla Android
I'm about to port a series of my jQuery projects over to Vanilla Javascript
I want to be able to create users that have a straight up SHA-1
I'm using the term partial to refer to a small section of presentational code

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.