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

  • Home
  • SEARCH
  • 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 8391499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:16:45+00:00 2026-06-09T19:16:45+00:00

Is it possible to specify thresholds for color-scales? Look at this example: xy <-

  • 0

Is it possible to specify thresholds for color-scales?

Look at this example:

xy <- expand.grid(x=1:20,y=1:20)
xyd <- data.frame(xy,z=runif(400),a=rowSums(xy)/40)
g <- ggplot(xyd, aes(x=x, y=y, fill=z, alpha=a)) + 
       geom_tile() + 
       scale_alpha(range=c(0,1), limits=c(0.5,1))
g

Scale_alpha only applies to values within the given limits

What I want is that Values of a below 0.5 get an alpha value of 0 so that the lower left half will be invisible. Obviously I could transform the original data but that would destroy the legend.

  • 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-09T19:16:46+00:00Added an answer on June 9, 2026 at 7:16 pm

    The threshold is working and the values outside that threshold are set to NA; the problem is that an alpha of NA is getting rendered as full opacity. Setting the na.value on the scale to 0 gets the results you want.

    ggplot(xyd, aes(x=x, y=y, fill=z, alpha=a)) + 
           geom_tile() + 
           scale_alpha(range=c(0,1), limits=c(0.5,1), na.value = 0)
    

    enter image description here

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

Sidebar

Related Questions

is it possible to specify the color for the row selector in silverlight grid
In SPSS 11 it was possible to specify relative paths. Example: FILE HANDLE myfile='..\..\data\current.txt'
Is is it possible to specify default type when parametrzing a class? Example: //
Is it possible to specify the table name in a many-to-many relationship? Example: class
Is it possible to specify alignment of parent class? for example something like (which
Is it possible to specify what color each section of the pie looks like?
I am wondering if it is possible to specify grid viewports with double like
Is it possible to specify a build action, for example install using Xcode GUI?
Is it possible to specify a lowercase only output when using Mcrypt? This is
Is it possible to specify include paths for C and C++ in a pkg-config

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.