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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:46:11+00:00 2026-06-07T01:46:11+00:00

I am plotting a number of data sets using ggplot2 in R. To make

  • 0

I am plotting a number of data sets using ggplot2 in R. To make the plots easier to compare, I am setting the limits of the y-scale, but, it turns out, nothing is plotted above the ‘natural top’ of the plot.

eg for this plot:
Plot with missing labels and lines
(source: sickel.net)

I have tried to set the top y-value to 500 (and looking at the white space at the top, I have managed to) but how to make ggplot also plot the labels for 400,450 and 500 and the corresponding grid lines?

the data are in the dataframe df with df$dataset and df$error as data and error-level respectively. My plotting code presently is

max = max(df$dataset + df$error) * 1.05
if(max > 300) max=505

dataplot = ggplot(data=df, aes(x=species,y=dataset,fill=dim,ylim=c(0,max)))
dataplot = dataplot+geom_bar(position=position_dodge())
dataplot = dataplot+scale_fill_manual(values=c("#BBBBBB", "#444444"))
dataplot = dataplot + ylab(ylab) + xlab(xlab) + opts(legend.title=theme_blank())

limits <- aes(ymax = df$dataset+df$error, ymin=df$dataset-df$error)
dodge = position_dodge(width=0.9)

dataplot = dataplot + geom_errorbar(limits, position=dodge, width=0.5) 
dataplot = dataplot + opts(panel.background = theme_rect(fill='white', colour='white'))
dataplot = dataplot + opts(panel.grid.major = theme_line(colour = "gray"))

# dataplot = dataplot + coord_cartesian(ylim=c(0, max))
# dataplot = dataplot + scale_y_continuous(limits=c(0, max))

dataplot = dataplot + 
               opts(axis.text.x = theme_text(colour = "black",angle=90),
                    axis.text.y = theme_text(colour = "black"))
dataplot = dataplot + opts(legend.key.size = unit(0.3, "cm"))
print(dataplot)

As can be seen from the commented out lines, I have tried coord_cartesian, scale_y_continous as well as the present y-lim without any luck (yes, and I know that coord_cartesian is zooming in)

  • 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-07T01:46:12+00:00Added an answer on June 7, 2026 at 1:46 am

    For the ylimits you can add:

    + scale_y_continuous(limits=c(0,500))
    

    In order to set the tick points, you can use:

    breaks=seq(0, 500, 50) # which means ticks from 0-500, every 50 units  
    

    Therefore, I think you need to add the code below to your plot code:

    +scale_y_continuous(limits=c(0,500),breaks=seq(0, 500, 50))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm plotting data in Python using matplotlib. I am updating the data of the
I'm plotting data which extent, in x, from -1000 to 1000. But I'm only
I need help in plotting date vs number graph using CorePlot. I have already
When plotting color-maps using gnuplot, I usually use the following lines: ... set palette
I am plotting boxplots from this data: MY_LABEL MY_REAL MY_CATEGORY 1 [POS] .56 POS
I'm plotting some data curves with gnuplot, and they look like this: However, the
I am plotting an array of pie charts, each using the same two colors
When using the d3 plotting library Rickshaw the renderer (either area, line, or bar)
I am looking for a plotting/graphing library (mostly to do line plots) for my
I am relatively new to R and am having trouble plotting grouped data against

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.