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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:39:24+00:00 2026-06-12T17:39:24+00:00

I’m trying to do a dotplot with the libraries lattice and latticeExtra in R

  • 0

I’m trying to do a dotplot with the libraries lattice and latticeExtra in R. However, no proper representation of the values on the vertical y-axis is done. Instead of choosing the actual values of the numeric variable, R plots the rank of the value. That is, there are values [375, 500, 625, 750, ..., 3000] and R plots their ranks [1,2,3,4,...23] and chooses the scale accordingly. Has someone experienced a problem like this? How can I manage the get a proper representation with ticks like (0, 500, 1000, 1500, ...) on the vertical y-scale?

Here the program code so far:

df.dose <- read.table("data.csv", sep=",", header=TRUE)
library(lattice); library(latticeExtra)

useOuterStrips(dotplot(z ~ sample.size | as.factor(effect.size)*as.factor(true.dose),
               groups=as.factor(type), data=df.dose, as.table=TRUE))

(Added from comment below): Also, can error bars be added to the graph? I thought of the following (to be added to the call), but it doesn’t seem to work. Is it possible somehow?

up=z+se, lo=z-se, panel.groups=function(x,y,..., up, lo, subscripts){ 
   up <- up[subscripts]
   lo <- lo[subscripts]
   panel.segments(lo, as.numeric(y), up, as.numeric(y), ...)
}

Here’s my data: https://www.dropbox.com/s/egy25cj00rhum40/data.csv

Added: here’s the relevant portion of the data using expand.grid and dput:

df.dose <- expand.grid(effect.size=c(-.5, -.625, -0.75),
                       sample.size=c(40L, 60L, 80L),
                       true.dose=c(375L, 500L, 750L, 1125L),
                       type=c("dose", "categ", "FP2", "FP1"))
df.dose$z <- c(875L, 875L, 750L, 750L, 750L, 625L, 625L, 625L, 625L, 875L, 
875L, 750L, 1000L, 1000L, 1000L, 1125L, 1000L, 875L, 1000L, 1000L, 
875L, 1000L, 1000L, 875L, 1125L, 1000L, 1000L, 1250L, 1125L, 
1000L, 1250L, 1250L, 1125L, 1250L, 1000L, 1000L, 500L, 500L, 
500L, 500L, 500L, 500L, 500L, 500L, 500L, 625L, 625L, 625L, 625L, 
625L, 625L, 625L, 625L, 625L, 750L, 750L, 625L, 750L, 750L, 750L, 
750L, 750L, 750L, 875L, 875L, 750L, 750L, 875L, 875L, 875L, 875L, 
875L, 2500L, 1500L, 1125L, 2000L, 1000L, 1750L, 250L, 500L, 500L, 
1250L, 750L, 625L, 875L, 500L, 500L, 875L, 500L, 375L, 1250L, 
875L, 750L, 1000L, 625L, 625L, 875L, 500L, 500L, 1125L, 1000L, 
875L, 1125L, 875L, 625L, 1125L, 1000L, 625L, 2500L, 2125L, 2375L, 
2000L, 750L, 2625L, 250L, 625L, 250L, 875L, 875L, 500L, 625L, 
500L, 625L, 1000L, 500L, 375L, 1000L, 875L, 625L, 875L, 500L, 
500L, 875L, 500L, 500L, 1250L, 1125L, 875L, 1125L, 875L, 750L, 
1250L, 1000L, 625L)
  • 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-12T17:39:25+00:00Added an answer on June 12, 2026 at 5:39 pm

    You need to makez a factor: dotplot(factor(z) ~ ...

    Also you probably want some jitter in the plot to prevent overlap; try adding jitter.x=TRUE or jitter.y=TRUE, or both.

    Judging by your comment below and looking at the data again, I think you’re plotting the dotplot the wrong way. I think you want the lines to be for the sample sizes, not for the z‘s. If you really want z on the vertical axis, you then need to add horizontal=TRUE. You could also swap what is on the horizontal and vertical axes.

    useOuterStrips(dotplot(z ~ factor(sample.size) | 
                                 as.factor(effect.size)*as.factor(true.dose),
                      groups=as.factor(type), data=df.dose,  
                      as.table=TRUE, horizontal=FALSE, jitter.x=TRUE))
    

    To add an error bar, it’s a little more complicated because you have groups within the panels, so you need to use a panel.groups function; additionally, so that the lines don’t overlap, you probably want to jitter them from side to side a little, which is best done in a custom panel function.

    df.dose$se <- 200
    df.dose$type <- factor(df.dose$type)
    df.dose$sample.size <- factor(df.dose$sample.size)
    
    panel.groups.mydotplot <- function(x, y, subscripts, up, lo, 
                                       col=NA, col.line=NA, ...) {
      panel.points(x, y, ...)
      panel.segments(x, lo[subscripts], x, up[subscripts], col=col.line, ...)
    }
    panel.mydotplot <- function(x, y, subscripts, groups, ..., jitter=0.1) {
      jitter <- seq(-1,1,len=nlevels(groups))*jitter
      xx <- as.numeric(x) + jitter[as.numeric(groups[subscripts])]
      panel.dotplot(x, y, groups=groups, subscripts=subscripts, pch=NA, ...)
      panel.superpose(xx, y, groups=groups, subscripts=subscripts,  
                      panel.groups=panel.groups.mydotplot, ...)
    }
    pp <- dotplot(z ~ sample.size | as.factor(effect.size)*as.factor(true.dose),
                  groups=type, data=df.dose, as.table=TRUE, horizontal=FALSE,
                  up=df.dose$z + df.dose$se, lo=df.dose$z - df.dose$se,
                  panel=panel.mydotplot, auto.key=list(space="right"))
    useOuterStrips(pp)
    

    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 am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.