chrisadolph/tile-simcf — Issue #24: In tile plots with axes on parallel sides, gridlines are automatically attached to both sides when the first is requested
Author: chrisadolph
Created: 2012-02-03 22:19:37+00:00
State: open

Tile offers users the option of including gridlines extending from the tick marks on any axis of a plot. (Technically, the actual ticks are then deleted to save space.) In a plot with an x-axis for which you want vertical gridlines at the x-ticks, you would include ```gridlines=list(type="x")``` in your tile call. Tile is supposed to pick on the letters ```x```, ```y```, ```top```, and ```right``` in the ```type``` argument above and add gridlines for any that appear. Thus ```gridlines=list(type="xy")``` should put gridlines on the x and y tick locations.

Currently, in plots that have a y and right axis, including ```gridlines=list(type="y")``` is adding gridlines at both the y and right tick locations. If these are different locations, the resulting plot is ugly and unreadable. This is a bug, but should be easy to fix. Note that the example below does not produce the bug for x and top axis gridlines, just y and right. We should check to make sure this bug is specific to y and right.

Code to reproduce the bug follows:

```R

library(tile)

# Load some data on height and weight; standardize
# from an undergrad course example on correlation
source("http://www.stat.ucla.edu/~cocteau/stat13/data/cdc.R")
cond <- (age==20)&(gender=="m")
w21 <- weight[cond]
h21 <- height[cond]/12
w21m <- mean(w21)
h21m <- mean(h21)
w21sd <- sd(w21)
h21sd <- sd(h21)

# Make a scatterplot trace of height and weight data
trace1 <- scatter(x=h21, y=w21,
fit=list(method="mmest",ci=NA),
plot=1)

#Limits on x and y axes; limits on top and right computed below
xmin <- 5
xmax <- 7
ymin <- 100
ymax <- 300

# Call tile; reproduce error
tile(trace1,
limits=c(xmin,xmax,ymin,ymax,
(xmin-h21m)/h21sd,
(xmax-h21m)/h21sd,
(ymin-w21m)/w21sd,
(ymax-w21m)/w21sd),
topaxis=list(add=TRUE, at=-3:4),
rightaxis=list(add=TRUE, at=-2:4),
xaxistitle=list(labels="Height in feet"),
yaxistitle=list(labels="Weight in pounds"),
topaxistitle=list(labels="Height in sd units"),
rightaxistitle=list(labels="Weight in sd units"),
width=list(yaxistitle=3.5, rightaxistitle=2.5),
height=list(topaxistitle=2.5, xaxistitle=2.5),
gridlines=list(type="xy")
)
```