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

The Archive Base Latest Questions

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

In ggplot2 I’m attempting a simple thing that I just can’t get for some

  • 0

In ggplot2 I’m attempting a simple thing that I just can’t get for some reason. I have adjusted means and SE in a data frame and want to plot the means, error bars and then connect the means with points. Here’s the code and the error (it does everything except connect the means with geom_line (working with RCookbook:

library(ggplot2)
#data set
data1 <- structure(list(group = structure(1:3, .Label = c("1", "2", "3"
), class = "factor"), estimate = c(55.7466654122763, 65.0480954172939, 
61.9552391704298), SE = c(2.33944612149257, 2.33243565412438, 
2.33754952927041), t.ratio = c(23.8290016171476, 27.8884844271143, 
26.5043535525714)), .Names = c("group", "estimate", "SE", "t.ratio"
), row.names = c(NA, 3L), class = "data.frame")

#the attempted plot
pd <- position_dodge(.1)
ggplot(data1, aes(x=group, y=estimate, group=group)) + 
    geom_errorbar(aes(ymin=estimate-SE, ymax=estimate+SE), 
        colour="black", width=.1, position=pd) +
    geom_line(data=data1, aes(x=group, y=estimate)) + 
    geom_point(position=pd, size=4)

the error:

ymax not defined: adjusting position using y instead
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
  • 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-11T16:33:22+00:00Added an answer on June 11, 2026 at 4:33 pm

    If you remove the grouping by group within the ggplot call and set x = as.numeric(group ) within the call to geom_line, the it works.

    Also, you don’t need to re-reference data1 within geom_line

    ggplot(data1, aes(x=group, y=estimate)) + 
      geom_errorbar(aes(ymin=estimate-SE, ymax=estimate+SE), 
      colour="black", width=.1, position=pd) +
      geom_line( aes(x=as.numeric(group), y=estimate)) + 
      geom_point(position=pd, size=4)
    

    enter image description here

    If you group by group, then you only have one value for geom_line to create a line from, hence the error message. The same error occurs if ggplot is considering the x or y mapping variables as a factor – this is because if you code a variable as a factor R (and ggplot) will consider them independent groups, and not connect the points – this is sensible default behaiviour.

    EDIT – with alphabetic factor labels

    This will work with alphabetic factor labels due to the way factors are coded internally by R (ie as.numeric(factor) returns numbers not the factor labels)

    ie.e

    Changing group to a, b, c

    levels(data1[['group']]) <- letters[1:3] 
    ggplot(data1, aes(x=group, y=estimate)) + 
      geom_errorbar(aes(ymin=estimate-SE, ymax=estimate+SE), 
      colour="black", width=.1, position=pd) +
      geom_line( aes(x=as.numeric(group), y=estimate)) + 
      geom_point(position=pd, size=4)
    

    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 have an ggplot2 point chart created like this qplot(Index, Popularity ,data = data.slopeone.agg)
From the documentation for ggplot2's geom_tile() function, we have the following simple plot: #
I have an object from ggplot2 , say myPlot , how can I identify
Can I use ggplot2 to produce a violin plot? Perhaps using some variation of
I have the following ggplot2 code that plots the ribbon from the 3rd to
I have R code (using ggplot2) that pumps out a bunch of charts to
I have written the following code: library(ggplot2) data <- structure(list(x = c(1L, 6L, 3L,
i am displaying time series data with ggplot2 but the tick-labels show some strange
I am using ggplot2 to plot simple line charts of time series data. One
I'm using ggplot2 and attempting to create an empty plot with some basic dimensions,

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.