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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:16+00:00 2026-05-25T20:37:16+00:00

I am trying to make a simple barplot but i have a problem that

  • 0

I am trying to make a simple barplot but i have a problem that I have duplicated names on x-axis. So when ever I am trying to write names on x-axis it does not show complete string. I have following data

x <- c(1.8405917,0.3265986,1.5723623,464.7370299,0.0000000,3.2235716,
       3.1223534, 7.0999787, 1.7122258,3.2005524,3.7531266,469.4436828)

and I am using barplot

barplot(x,xlab=c("AA/AA","AA/CC","AA/AC","AA/NC","CC/AA","CC/CC","CC/AC",
                 "CC/NC","AC/AA","AC/CC","AC/AC","AC/NC"))

But it does not work. I also used

axis()

But it does not work as well.

Thanks in advance.

  • 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-25T20:37:16+00:00Added an answer on May 25, 2026 at 8:37 pm

    No, xlab is for providing a label for the entire x-axis of the plot, not for labelling the individual bars.

    barplot() takes the labels for the bars from the names of the vector plotted (or something that can be derived into a set of names).

    > names(x) <- c("AA/AA", "AA/CC", "AA/AC", "AA/NC", "CC/AA", "CC/CC", "CC/AC",
    +               "CC/NC", "AC/AA", "AC/CC", "AC/AC", "AC/NC")
    > barplot(x)
    > ## or with labels rotated, see ?par
    > barplot(x, las = 2)
    

    Edit: As @Aaron mentions, barplot() also has a names.arg to supply the labels for the bars. This is what ?barplot has to say:

    names.arg: a vector of names to be plotted below each bar or group of
    bars. If this argument is omitted, then the names are taken
    from the names attribute of height if this is a vector,
    or the column names if it is a matrix.

    Which explains the default behaviour if names.arg is not supplied – which is to take the names from the object plotted. Which usage is most useful for you will mainly be a matter of taste. Not having the row/column/names might speed code up slightly, but many of R’s functions will take the names attribute (or similar, e.g. row names) directly from objects so you don’t have to keep providing labels for plotting/labelling of results etc.

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

Sidebar

Related Questions

I am trying to make simple testing but failed because I have no clue
I am trying to make a simple program that handles files and directories, but
I'm trying to make a simple C# web server that, at this stage, you
I'm trying to make some simple XML with Java and org.w3c.dom, but I got
I'm trying to make a simple drawing app in c++, but i'm having trouble
I'm trying to make simple many-to-one association, using NHibernate.. I have class Recruit with
I am trying to make simple regex that will check if a line is
Trying to make simple jQuery function to create a scrollToTop button that fades in
I am trying to make simple app that allows one to compare image to
I am trying to make a simple query to a small MYSQL table, but

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.