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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:19:50+00:00 2026-06-06T10:19:50+00:00

I need to plot some discrete predictions with probability intervals in ggplot2, but I’m

  • 0

I need to plot some discrete predictions with probability intervals in ggplot2, but I’m having some problems.

I have the following data.frame

city    pred    min.80    max.80
BH      100     50        150
RJ      120     80        140
SP      90      80        100

I want a plot with the cities on y-axis and the predicted values on x-axis. For each discrete value of y, there should be a horizontal bar with its range being the min.80 and max.80 values. My idea is to use geom_rect from ggplot2 for doing it.

I’ve tried the following code, but the problem is that I’m converting the discrete variable to continuous in order to plot it, and I lose their values on the label.

> ggplot(df) + geom_rect(aes(xmin=min.80, xmax=max.80, ymin=as.numeric(city)-0.4,
+ ymax=as.numeric(city)+0.4))

Is there another way to do it?

  • 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-06T10:19:51+00:00Added an answer on June 6, 2026 at 10:19 am

    I suggest you use the geom pointrange or crossbar:

    ggplot(df, aes(x=city)) + 
      geom_pointrange(aes(ymin=min.80, ymax=max.80, y=pred)) +
      coord_flip()
    

    enter image description here

    ggplot(df, aes(x=city)) + 
      geom_crossbar(aes(ymin=min.80, ymax=max.80, y=pred)) +
      coord_flip()
    

    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 need to read some data from an input file and plot a graph
I have plotted a contour map but i need to make some improvements. This
I need to plot some data in various forms. Currently I'm using Matplotlib and
I have some data I need to display using MSChart, I am looking to
I have recently been working with the highchart api to plot some data on
I have some problems with figures in Matlab. I divided my bar plot into
I have following data and plot: pos <- rep(1:2000, 20) xv =c(rep(1:20, each =
I need plot a curve for my data , the source is like :
Hi I need to plot a boxplot in R. I have two matrices a
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.