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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:54:03+00:00 2026-06-15T21:54:03+00:00

To highlight the difference between two identically sized matrices I would like to show

  • 0

To highlight the difference between two identically sized matrices I would like to show the two superimposed in a semitransparent way using shades of red for the one matrix and shades of green for the other one (yielding yellow where they are identical) in R.

To display just one matrix I have

library(grDevices)
matr=replicate(10, rnorm(20,mean=0.5,sd=0.1))    
colpalette=colorRampPalette(c("black", "red")) 
image(matr^0.2,col = colpalette(1000),useRaster=T)

Does any one have any idea how I should adapt this to show two matrices matr1 and matr2 superimposed in red/green?

Also, what would be the best way to have a bit of control over the brightness & contrast of the resulting image? Are there better ways than the power transform I am using now?

cheers,
Tom

  • 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-15T21:54:04+00:00Added an answer on June 15, 2026 at 9:54 pm

    Ha just found an easy solution by first calculating the log2(difference) between the two matrices and plotting that using a palette with a break at zero. That makes sense, right?

    library(grDevices)
    matr1=replicate(10, rnorm(20,mean=0.5,sd=0.1)) 
    matr2=replicate(10, rnorm(20,mean=0.5,sd=0.1))
    matrdiff=log2(matr1/matr2)
    nbcolors=1000
    colpalette=colorRampPalette(c("red","yellow","green"))(nbcolors)
    breaks = c(seq(min(matrdiff), 0, length.out=nbcolors/2), 0, 
               seq(0,max(matrdiff), length.out=nbcolors/2))
    image(matrdiff,col=colpalette,breaks=breaks,useRaster=T)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to show the differences between two blocks of text. Rather than
What is the easiest way to highlight the difference between two strings in PHP?
I'm looking for a way to determine the differences between two strings, and highlight
I have two matrices (of approximately 300 x 100) and I would like to
I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive.
Please highlight the difference between the following function declarations: void (*p) (void *a[], int
I'm trying to find a good way to have version comparison between two files
I am trying to create a formula for calculating the percentage difference between two
Is there any performance difference (in C++) between the two styles of writing if-else,
Can someone highlight on the differences between these two and the instances both are

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.