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

The Archive Base Latest Questions

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

How can I centre the labels on the x-axis to match up with the

  • 0

How can I centre the labels on the x-axis to match up with the bars? Also, how can I position the x axis label further down so it it is not obscured by the x-axis labels? Thanks!

par(mar= c(15,4,4,2) + 0.1)
barplot(58:1,xaxt="n",xlab="",ylab="Frequency", col=gray(5:0/5))
axis(1, labels=FALSE)
text(1:58, par("usr")[3] - 0.25, srt = 90, adj = 1,
labels = rep("Long Species Name",58), xpd = TRUE)
mtext(1, text = "Species", line=6)

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-09T05:17:01+00:00Added an answer on June 9, 2026 at 5:17 am

    Check out the return value of barplot() (by reading ?barplot). There we find that the mid points of the bars are returned by the function as a vector. Hence it is a simple matter of assigning the returned object (here to object bar) and then use that in a call to axis() to locate the tick marks.

    In the axis() call, note that we specify both the labels argument and the at argument, with at being set to the bar mid points as stored in bar. las = 2 is used to rotate the labels relative to the axis, and cex.axis = 0.6 is used to reduce the label size.

    The second part of your question is handled by title() and the line argument. First note that when you set the mar parameter you are setting the margin size in “lines”, hence the margin on side 1 (bottom) is 15 lines. The line argument in title() specifies which of the margin lines you want to draw the axis label.

    Putting this altogether with a modified example we have:

    op <- par(mar= c(15,4,4,2) + 0.1)
    bar <- barplot(58:1, xaxt="n", xlab="", ylab="Frequency", col=gray(5:0/5))
    axis(1, labels = paste("Long Species Name", 1:58), at = bar,
         las = 2, cex.axis = 0.6)
    title(xlab = "Species", line=11)
    par(op)
    

    Which produces:

    barplot produced using example code

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

Sidebar

Related Questions

How can one image be rotated with axis of rotation as image centre using
By removing a field in a fieldset, it's label is not removed. How can
how can i centre the list items in the nav bar, list items are
I'd like to use the inline labels of the bootstrap css framework: <span class=label>Default</span>
For some reason, I can't update the second label. I tested it by asking
Brain not working today - can anyone give me a regexp that would turn:
I am using JFreeChart 1.0.14 . The labels of my axis stretch really strangely
I want to create labels that the text in them can be selected for
How can I change each labels first character except the last labels character $
I'm trying to do a kind of gallery wich can center to the most

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.