legend error using saveGIF
weianuk opened this issue · comments
When I was using saveGIF using the code below,
saveGIF(
{ for (i in 1:5) {
function
legend(x="topleft",legend = c("1", "2","3","4","5","6"),
fill = c("red", "green","yellow", "blue","purple","grey"), bty = "n")
}
},
interval = 0.1, ani.width = 550, ani.height = 550
)
it gave the error of the legend:
[1] 1
Error in strwidth(legend, units = "user", cex = cex, font = text.font) :
plot.new has not been called yet
In addition: Warning messages:
1: fullpage and expand syntaxes deprecated, use extent.
2:panel.margin
is deprecated. Please usepanel.spacing
property instead
- Is there any setting about the legend incorrect?
- When I want to enlarge the figure by changing ani.width and ani.height, nothing happened. Is there still something wrong?
Hope for helps on my problem.
@yulijia @yihui
Thanks in advance.
I cannot repeat your code. what is function
?
But I can run the demo successfully as shown below.
saveGIF(
{ for (i in 1:5) {
plot(rnorm(10))
legend(x="topleft",legend = c("1", "2","3","4","5","6"),
fill = c("red", "green","yellow", "blue","purple","grey"), bty = "n")
}
},
interval = 0.1, ani.width = 550, ani.height = 550
)
@yulijia Thanks for your prompt reply. Function is a complex block that calls many other subfunctions and ggmap, so it is hard to put here. But I realised the error is the legend setting using ggmap.
If you don't have further questions, I will close this issue.