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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:01:52+00:00 2026-06-14T07:01:52+00:00

Earlier I asked about creating a gradient of n values in base graphics (

  • 0

Earlier I asked about creating a gradient of n values in base graphics (LINK). Now I’d like to create a gradient legend that goes with it. My ideal would be something like ggplot2‘s gradient legends:

enter image description here

Here’s some code similar to what I’m working with:

colfunc <- colorRampPalette(c("red", "blue"))
plot(1:20, 1:20, pch = 19, cex=2, col = colfunc(20))

enter image description here

  • 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-14T07:01:53+00:00Added an answer on June 14, 2026 at 7:01 am

    Here is an example of how to build a legend from first principles using rasterImage from grDevices and layout to split the screen

    layout(matrix(1:2,ncol=2), width = c(2,1),height = c(1,1))
    plot(1:20, 1:20, pch = 19, cex=2, col = colfunc(20))
    
    legend_image <- as.raster(matrix(colfunc(20), ncol=1))
    plot(c(0,2),c(0,1),type = 'n', axes = F,xlab = '', ylab = '', main = 'legend title')
    text(x=1.5, y = seq(0,1,l=5), labels = seq(0,1,l=5))
    rasterImage(legend_image, 0, 0, 1,1)
    

    enter image description here

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

Sidebar

Related Questions

i had asked earlier about the same kind of question but that was in
Okay, I had asked a question earlier about how I could create my own
I asked a question earlier today about log4j and was told that it is
In an earlier post I asked about how to create short form for my
Earlier today I asked a question about passing dictionary values to a function. While
I asked this question earlier about testing a controller action and verifying that a
This is related to this question I asked earlier about syntax highlighting user-defined blocks
Ok, I asked about this very error earlier this week and had some very
Earlier today, I asked a question about the way Python handles certain kinds of
I asked a question earlier about why left joins in Linq can't use defined

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.