r - latticeExtra doubleYScale, problems retaining original log-scale formatting -
similar question posed troels in 2014, in example below, both plot1 , plot2 formatted intended. in superimposed plot, original log-scale formatting lost on y2 axis: reverts clunky '^' format. problem (secondary) can't change size of ylab2 title without losing label entirely. have searched , tried various code (e.g., 'update' .) no avail. below script - ease of replication, using "diamonds" data set ggplot2 package (plots not make sense).
require(ggplot2) #access "diamonds" dataset require(dplyr) require(latticeextra) # generate mock dataframe example mock <- diamonds %>% select(clarity, depth, price) %>% filter(price>1000 & row_number()<1000) %>% mutate(newvar = sample(1000, size = nrow(mock), replace = true)) plot1 <- xyplot(price ~ depth | clarity, mock, as.table=true, grid=true, type = c("p", "r"), lwd=1, pch=16, xlab=list(label="depth", cex=0.9), ylab =list(label="price", cex=0.9), main="how retain original plot2 scale labels in superimpose?", par.settings = list( layout.widths = list(ylab.axis.padding=2.5))) plot2 <- xyplot(newvar ~ depth | clarity, mock, as.table=true, grid=true, type = c("p", "r"), lwd=1, pch=16, scales=list(y=list(log=t, equispaced.log = false)), # above refine y-axis labels - i.e., remove "^" (not retained in overlay) ylab = "newvar (units)") # last code call gets retained in overlay # ylab = list(label="newvar(units)", cex=0.9))... not #superimposing 2 plots doubleyscale(plot1, plot2, style1 = 0, style2 = 3, add.ylab2 = t, add.main=t) for "combinelimits", deepayan states "in particular, log-scales not yet work." case doubleyscale? know type of plot discouraged, dataset helpful visualizations. have same problem if both y1 , y2 log-scale. in advance, -susan
Comments
Post a Comment