ggplotly图在jupyterlab中无法正确显示

时间:2020-01-14 20:45:24

标签: r ggplot2 jupyter jupyter-lab ggplotly

当我在ggplotly中使用jupyterlab时,输出将被截断。如何强制jupyter正确显示它? 由于某些原因,如果我只使用ggplot,则图可以根据需要而变大

    set.seed(1L)                                                                                                                             
    values <- rnorm(n = 366L)                                                                                                                
    plot_data <- data.frame(date = seq(as.Date("2011-01-01"), as.Date("2012-01-01"), 1),                                                     
                            value = values,                                                                                                  
                            sign = ifelse(values > 0, "positive", "negative"), size = ifelse(abs(values) > 2, "big", "small")                
                            )                                                                                                                
    p <- ggplot(data = plot_data) + aes(x = date, y = value, color = sign) + geom_line()                                                     
                                                                                                                                             
    vertical <- as.Date(c("2011-02-01", "2011-10-01"))                                                                                       
    names(vertical) <- c("test", "test2")                                                                                                    
    p <- p + geom_vline(xintercept = vertical, linetype = "dashed", color = "orange")                                                        
                                                                                                                                             
    data_geom <- data.frame(v_x = vertical, v_label = names(vertical), v_y = rep(2.5, 2))                                                    
    p <- p + geom_text(data = data_geom, aes_string(x = "v_x", label = "v_label", y = "v_y"), colour = "orange", angle = 90, check_overlap = TRUE)
    ggplotly(p)

这给了我

enter image description here

0 个答案:

没有答案