Reputation: 345
I have created a simple line chart in plotly using ggplot2 and placed the plot in a box using box() function. However the plot overshoots the screen and I wish to resize the plot. Please help me with the same.
library(plotly)
datn <- read.table(header=TRUE, text='
supp dose length
OJ 0.5 13.23
OJ 1.0 22.70
OJ 2.0 26.06
VC 0.5 7.98
VC 1.0 16.77
VC 2.0 26.14
')
p <- ggplot(data=datn, aes(x=dose, y=length, group=supp, colour=supp)) +
geom_line() +
geom_point()
p <- ggplotly(p)
Upvotes: 2
Views: 6487
Reputation: 2067
EDIT: sorry, I missed your comment that you were using box()
to add a plot border (it wasn't in your example code). I'd recommend instead using ggplot2's panel border functionality:
p = p +
theme(panel.border = element_rect(colour = "black", fill = NA, size = 3))
ORIGINAL: The code you've supplied isn't overshooting on my laptop:
But if you need to, you can supply
ggplotly()
with explicit height and width arguments:
ggplotly(p, width = 500, height = 200)
The function has some other nice arguments for controlling the appearance of your plot.
Upvotes: 5