On Thursday, 20 July 2017 04:24:50 UTC-6, Thomas Judson wrote: > > I am pretty sure that this is an R problem that occurs because of linked > cells. Look at > http://faculty.sfasu.edu/judsontw/math-s304/section-16.html. The first > plot works fine, but somehow I need to clear the previous graphics when I > create a new plot. I have tried dev.off() and graphics.off(), but neither > works. Any ideas? >
OK, thanks a lot for the full example, I think this is the reason: https://github.com/sagemath/sagecell/blob/master/js/session.js#L327 R-cells have device.off() added automatically so that plotting commands that were given by users will all flush to a file that will be automatically displayed. Because R has these "live plots" that you can add stuff to, dealing with them in SageMathCell is a bit tricky. Not sure what is the best solution - perhaps in addition to "closing" commands I should add commands to initialize a new plot so that it is ready for the next cell if it exists? > > On Thursday, July 20, 2017 at 12:53:35 AM UTC+2, Andrey Novoseltsev wrote: >> >> On Wednesday, 19 July 2017 05:23:00 UTC-6, Thomas Judson wrote: >>> >>> The following code works in CoCalc >>> >>> cases <- c(36, 531, 4233, 8682, 7164, 2229, 600, 164, 57, 722, 1517, >>> 1828, 1539, 2416, 3148, 3465, 1440) >>> deaths <- c(0, 0, 130, 552, 738, 414, 198, 90, 56, 50, 71, 137, 178, >>> 194, 290, 310, 149) >>> plot(ts(cases), col="red", main="Influenza Epidemic") >>> lines(ts(10*deaths),col="blue”) >>> >>> However, I get the following error when I try to plot this in a Sage cell >>> >>> Error in plot.new() : cairo error 'error while writing to output stream' >>> Error in plot.xy(xy.coords(x, y), type = type, ...) : >>> plot.new has not been called yet >>> >>> >>> I may or may not get the plot. >>> >>> >>> Other R plots seem to work in the Sage cells. Any ideas? >>> >>> >>> Tom >>> >>> >>> >> I've tried it ten times or so and got the plot with no errors every time. >> Can you reproduce it in your setup reliably? I don't have any clue what can >> be wrong here that it works sometimes but not always... >> > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.