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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:32:12+00:00 2026-05-29T07:32:12+00:00

ggplot2 adjust the ylim automatically for the data points. Is there any way to

  • 0

ggplot2 adjust the ylim automatically for the data points. Is there any way to adjust the ylim for stat_summary too?

df <- structure(list(Varieties = structure(c(2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L), .Label = c("F9917", "Hegari", "JS263",
"JS2002"), class = "factor"), Priming = structure(c(2L, 2L, 2L,
2L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 4L, 4L, 4L,
4L, 2L, 2L, 2L, 2L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 1L, 1L, 1L,
1L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 5L, 5L, 5L, 5L, 3L, 3L, 3L,
3L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L), .Label = c("CaCl2", "Dry",
"Hydropriming", "KNO3", "OnFarmpriming"), class = "factor"),
    PH = c(225.8, 224.26, 228.9, 215.82, 230.3, 227.7, 232.8,
    221.1, 260.2, 230.8, 236.75, 230.5, 250.56, 230.74, 240.64,
    226.7, 268.4, 233.4, 243.33, 232.7, 252.04, 233.1, 237.14,
    220.6, 265.55, 234.93, 240.04, 218.21, 300.55, 245, 243.5,
    234.65, 253.3, 233.5, 238.62, 225.93, 255.74, 233.64, 238.1,
    230.93, 246, 240.33, 246.08, 221.7, 250.54, 242.87, 251,
    225.32, 251.47, 245.4, 266.74, 227.73, 290.62, 246.68, 256.4,
    225.83, 282.67, 240.58, 258.35, 235.87)), .Names = c("Varieties",
"Priming", "PH"), class = "data.frame", row.names = c(NA, 60L
))

p1 <- ggplot(data=df, aes(x=Varieties, y=PH, group=Priming, shape=Priming, colour=Priming))+
     stat_summary(fun.y=mean, geom="point", size=2, aes(group=Priming, shape=Priming, colour=Priming))+
     theme_bw()
p1 <- p1 + stat_summary(fun.y=mean, geom="line", aes(group=Priming, shape=Priming, colour=Priming))
print(p1)

See

See extra space in ylim for stat_summary values. Thanks in advance for your help and time.

  • 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-29T07:32:13+00:00Added an answer on May 29, 2026 at 7:32 am

    Here is one approach, using plyr to prep the data before plotting

    df <- ddply(df, .(Varieties, Priming), transform, meanPH = mean(PH))
    ggplot(df, aes(Varieties, meanPH)) + 
      geom_point() +
      geom_line(aes(group = Priming, color = Priming))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written the following code: library(ggplot2) data <- structure(list(x = c(1L, 6L, 3L,
I'm trying to make this logistic regression graph in ggplot2 . df <- structure(list(y
is there a way in ggplot2 to get the plot type "b"? See example:
library(ggplot2) This code produces a nice looking plot: qplot(cty, hwy, data = mpg, colour
I have a scatter plot in R (with ggplot2). The data has a numeric
I am looking for the way to annotate axis in ggplot2. The example of
I have simple histogram, but can't adjust the binwidth: qplot(factor(size_class),data=mydf,geom=histogram,binwidth = 0.01) size_class is
I'm trying to plot heatmap in ggplot2 using csv data following casbon's solution in
Possible Duplicate: List of ggplot2 options? I have a pretty basic question on ggplot2.
I am getting a small problem using ggplot2 geom_line graph. When I apply ylim

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.