开发者

Create qplots (with ggplot2) larger than the window?

开发者 https://www.devze.com 2022-12-22 07:49 出处:网络
I have a large chart with many data points. When I create the qplot in R, the chart is auto-fitted to the window. Even if I maximize the window, the chart is still too small and details are lost. I wo

I have a large chart with many data points. When I create the qplot in R, the chart is auto-fitted to the window. Even if I maximize the window, the chart is still too small and details are lost. I would like to save it as a large PNG and then look at certain areas at 1:1 resolution with an image viewer (as I cannot zoom in easily in R)开发者_如何学编程. Rendering the chart for a range of the values is not really convenient, I'd like to have one PNG and scroll around and discuss it with my peers, rather than pre-generating a bunch of subgraphs.

Is this possible? I kind of expect to be so, but some help would be appreciated (I've recently started with R so am still finding my way around).

Thank you.


One way would be:

myfile <- tempfile()                   # portable across OSs
pdf(file=myfile, height=20, width=20)  # 20x20 inches, adjust at will
plot(....)                             # or print(....) for lattice + ggplot2
dev.off()                              # finalize and close file
cat("Look at", myfile, "\n")

and now inspect the chart in the temp. file just created with a proper pdf viewer allowing you to zoom at will.


Check out this previous question and the answers:

Basically, you can use the Cairo package to create svg files, which are vector based, not pixel based, I can then edit these in Inkscape and i think you can view them direct in firefox (???).

library(Cairo)
Cairo(600,600,file="testplot.svg",type="svg",bg="transparent",pointsize=8, units="px",dpi=400)
testplot
dev.off()
Cairo(1200,1200,file="testplot12200.png",type="png",bg="transparent",pointsize=12, units="px",dpi=200)
testplot
dev.off()

Now I had to play around with the various settings to get my plot as good as it can be before writing the file. (critical settings seem to be the pointsize, which varies the size of the points on the graph, the size, obviously, and the dpi)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号