alexpkeil1 / qgcomp

QGcomp (quantile g-computation): estimating the effects of exposure mixtures. Works for continuous, binary, and right-censored survival outcomes. Flexible, unconstrained, fast and guided by modern causal inference principles
27 stars 6 forks source link

adjusting survival plot yaxis #24

Closed sethfrnd closed 1 year ago

sethfrnd commented 1 year ago

I have been attempting to adjust the yaxis using ylim as in a ggplot2 object, but I have been unsuccessful. Any suggestions?

alexpkeil1 commented 1 year ago

Try this (ylim is dangerous as a general tool because it can truncate the data):

library(qgcomp)
library(ggplot2)
set.seed(50)
N=200
dat <- data.frame(time=(tmg <- pmin(.1,rweibull(N, 10, 0.1))), 
                  d=1.0*(tmg<0.1), x1=runif(N), x2=runif(N), z=runif(N))
expnms=paste0("x", 1:2)
f = survival::Surv(time, d)~x1 + x2
(obj <- qgcomp.cox.boot(f, expnms = expnms, data = dat, B=10, MCsize=2000))

p = plot(obj, suppressprint = TRUE)
p + coord_cartesian(ylim=c(.5, 1))
sethfrnd commented 1 year ago

This works great! Thank you! The code works on my home computer. Unfortunately, it doesn't seem to work on the remote desktop I'm using. p returns as NULL Must be an issue with the remote desktop.

alexpkeil1 commented 1 year ago

Closing this with additional suggestion to save the plot (p object) to file on remote. ggsave() or png() may both work, depending on graphics environment, but how your remote desktop handles printing ggplot2 objects is beyond scope here. Let me know if this is a unique issue to the package though (i.e. do you have the same issue with standard ggplot2 objects that you save?), and I can search for more systematic fixes in the underlying qgcomp::plot code.

alexpkeil1 commented 1 year ago

Did you try saving it with ggsave?

On Aug 30, 2022, at 7:42 PM, sethfrnd @.***> wrote:

 This works great! Thank you! The code works on my home computer. Unfortunately, it doesn't seem to work on the remote desktop I'm using. p returns as NULL Must be an issue with the remote desktop.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.