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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:59:18+00:00 2026-05-30T17:59:18+00:00

When plotting only the legend (of a raster object – a colorbar): require(raster) r

  • 0

When plotting only the legend (of a raster object – a colorbar):

require(raster)
r = raster()
r[] = 1
plot(r, legend=F)
plot(r, zlim=c(-10,10), legend.only=T)

how can I control the legend axis label size, tick length, and other legend properties? I know I can call par(...) before the last plot() call, but is there a cleaner way?

  • 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-30T17:59:19+00:00Added an answer on May 30, 2026 at 5:59 pm

    You can pass axis.args and legend.args as arguments to the legend only function call, as for image.plot in the fields package.

    For example, to specify tick positions and labels, and to reduce tick label size, the following should do the trick. It will also accept arguments such as legend.width and legend.shrink.

    require(raster)
    data(volcano)
    r <- raster(volcano)
    plot(r, col=topo.colors(100), legend=FALSE, axes=FALSE)
    r.range <- c(minValue(r), maxValue(r))
    plot(r, legend.only=TRUE, col=topo.colors(100),
         legend.width=1, legend.shrink=0.75,
         axis.args=list(at=seq(r.range[1], r.range[2], 25),
                        labels=seq(r.range[1], r.range[2], 25), 
                        cex.axis=0.6),
         legend.args=list(text='Elevation (m)', side=4, font=2, line=2.5, cex=0.8))
    

    legend only - arguments

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

Sidebar

Related Questions

I'm plotting on top of an image in Matlab. Sometimes, I can't see what's
Using the ZedGraph control, say I am plotting data that has Y values of
Possible Duplicate: Plotting 4 curves in a single plot, with 3 y-axes assuming I
Possible Duplicate: Plotting 4 curves in a single plot, with 3 y-axes I have
I am plotting a continuous variable against a factor using plot() in R (see
I am plotting some curves using twin-axis and also scientific notation. I have set
How can I make it such that plotting the following function ListPointPlot3D[points, PlotStyle ->
I'm plotting data which extent, in x, from -1000 to 1000. But I'm only
This is a popular interview question and the only article I can find on
I've implemented a plotting class that is currently capable of handling integer values only.

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.