如何以 png 作为背景进行绘图?
我制作了一个 300 万点的图并将其保存为 PNG。花了几个小时,我想避免重新绘制所有点。
如何生成以此 PNG 作为背景的新绘图?
I made a plot with a 3 million points and saved it as PNG. It took a few hours and I would like to avoid re-drawing all the points.
How can I generate a new plot that has this PNG as a background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
下面是情节。
Try this:
Below is the plot.
虽然@bill_080的答案直接回答了你的问题,但这真的是你想要的吗?如果您想在其上绘图,则必须仔细对齐坐标系。请参阅例如 休斯顿犯罪地图 如何使用 ggplot2 完成此任务。
对于你的问题,在我看来,可能有一个更简单的解决方案:分箱,即ceating 2d直方图。
hexbin 直接与lattice 和 ggplot2 配合使用,但 bin 的中心坐标位于 binned@ 中xcm 和
binned@ycm
,因此您还可以在基础图形中绘制结果。通过大量的垃圾箱,您可以获得原始图的快速版本:但您可以轻松地拥有颜色编码密度:
While @bill_080's answer directly answers your question, is this really what you want? If you want to plot onto this, you'll have to carefully align your coordinate systems. See e.g. Houston Crime Map how this can be done with ggplot2.
For your problem, it seems to me that there may be an easier solution: binning, i.e. ceating 2d histograms.
hexbin works directly with lattice and ggplot2, but the center coordinates of the bins are in
binned@xcm
andbinned@ycm
, so you could also plot the result in base graphics. With high number of bins, you get a fast version of your original plot:but you can easily have the colours coding the density: