#Data generating process
x<-rnorm(100, 0, 2)
#we generated a normal sample with mean 0 and standard deviation 2
png("path/to/file.png")
plot.ts(x)
dev.off()
After running this short script, no screen output is produced but path/to/file.png is created as a png image. After calling this script from Java, produced image can be loaded like this:
ImageIcon myIcon = new ImageIcon("/path/to/file.png");
This image can be easly drawn on a swing container using
public void paintComponent(Graphics g) { super.paintComponent(g); myIcon.paintIcon(this, g, 0, 0); }