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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:20:11+00:00 2026-06-18T08:20:11+00:00

I saved my data in as a .csv file with 12 columns. Columns two

  • 0

I saved my data in as a .csv file with 12 columns. Columns two through 11 (labeled F1, F2, ..., F11) are features. Column one contains the label of these features either good or bad.

I would like to plot a boxplot of all these 11 features against the label, but separate by good or bad. My code so far is:

qplot(Label, F1, data=testData, geom = "boxplot", fill=Label, 
          binwidth=0.5, main="Test") + xlab("Label") + ylab("Features")

However, this only shows F1 against the label.

My question is: How to show F2, F3, ..., F11 against the label in one graph with some dodge position? I have normalized the features so they are in the same scale within [0 1] range.

The test data can be found here. I have drawn something by hand to explain the problem (see below).

hand-drawn boxplot example

  • 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-18T08:20:12+00:00Added an answer on June 18, 2026 at 8:20 am

    You should get your data in a specific format by melting your data (see below for how melted data looks like) before you plot. Otherwise, what you have done seems to be okay.

    require(reshape2)
    df <- read.csv("TestData.csv", header=T)
    # melting by "Label". `melt is from the reshape2 package. 
    # do ?melt to see what other things it can do (you will surely need it)
    df.m <- melt(df, id.var = "Label")
    > df.m # pasting some rows of the melted data.frame
    
    #     Label variable      value
    # 1    Good       F1 0.64778924
    # 2    Good       F1 0.54608791
    # 3    Good       F1 0.46134200
    # 4    Good       F1 0.79421221
    # 5    Good       F1 0.56919951
    # 6    Good       F1 0.73568570
    # 7    Good       F1 0.65094207
    # 8    Good       F1 0.45749702
    # 9    Good       F1 0.80861929
    # 10   Good       F1 0.67310067
    # 11   Good       F1 0.68781739
    # 12   Good       F1 0.47009455
    # 13   Good       F1 0.95859182
    # 14   Good       F1 1.00000000
    # 15   Good       F1 0.46908343
    # 16    Bad       F1 0.57875528
    # 17    Bad       F1 0.28938046
    # 18    Bad       F1 0.68511766
    
    require(ggplot2)
    ggplot(data = df.m, aes(x=variable, y=value)) + geom_boxplot(aes(fill=Label))
    

    boxplot_ggplot2

    Edit: I realise that you might need to facet. Here’s an implementation of that as well:

    p <- ggplot(data = df.m, aes(x=variable, y=value)) + 
                 geom_boxplot(aes(fill=Label))
    p + facet_wrap( ~ variable, scales="free")
    

    ggplot2_faceted

    Edit 2: How to add x-labels, y-labels, title, change legend heading, add a jitter?

    p <- ggplot(data = df.m, aes(x=variable, y=value)) 
    p <- p + geom_boxplot(aes(fill=Label))
    p <- p + geom_jitter()
    p <- p + facet_wrap( ~ variable, scales="free")
    p <- p + xlab("x-axis") + ylab("y-axis") + ggtitle("Title")
    p <- p + guides(fill=guide_legend(title="Legend_Title"))
    p 
    

    ggplot2_geom_plot

    Edit 3: How to align geom_point() points to the center of box-plot? It could be done using position_dodge. This should work.

    require(ggplot2)
    p <- ggplot(data = df.m, aes(x=variable, y=value)) 
    p <- p + geom_boxplot(aes(fill = Label))
    # if you want color for points replace group with colour=Label
    p <- p + geom_point(aes(y=value, group=Label), position = position_dodge(width=0.75))
    p <- p + facet_wrap( ~ variable, scales="free")
    p <- p + xlab("x-axis") + ylab("y-axis") + ggtitle("Title")
    p <- p + guides(fill=guide_legend(title="Legend_Title"))
    p 
    

    ggplot2_position_dodge_geom_point

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

Sidebar

Related Questions

I have a large csv file with approximately 170 columns' worth of numerical data
I have a data set that is saved as a .csv file that looks
I have a datatable which contains yearly data saved. e.g. dtDate Value 2010-01-01 00:00:00.000
I have a raw image file that is saved in binary data (no encoding).
I have to extract data from a saved search and drop each column into
I have a simple csv file containing 2 columns of numbers with the headers
I am trying to create a .csv file with data that I have stored
I have about 100GB of data saved in ~10MB .csv files. How can I
I'm using db2 export to save data to a CSV file. Ultimately I need
I have a text file that contains 57,600,000 million lines of values. These values

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.