是否可以使用自定义图片作为条形图中的条形图?

时间:2017-12-12 17:07:02

标签: r excel data-visualization tableau business-intelligence

我有想要绘制的数据,而不是显示y轴值的常规垂直条,我想要:

1)用图片(例如圣诞装饰图案)填满酒吧

2)使用自定义图片(例如蜡烛,让我们说)作为栏

这可能吗?我首选的平台是R,Excel或Tableau public。

2 个答案:

答案 0 :(得分:5)

你可以尝试

library(jpeg)
library(grid)
library(lattice)

#download Chrismas tree image which will be used as bar in barplot
download.file("https://upload.wikimedia.org/wikipedia/commons/f/fa/Poinsettia_tree.jpg", "Poinsettia_tree.jpg")
chrismas_tree <- readJPEG("Poinsettia_tree.jpg")

#sample data for barplot
counts <- table(mtcars$gear)

#barplot
barchart(counts, origin=0, col="white",horizontal = FALSE,
             panel=function(x, y, ...) {
             panel.barchart(x, y, ...)
             grid.raster(chrismas_tree, y=0, height=y, x=x,
                               default.units="native", 
                               just="bottom",
                               width=unit(0.2,"npc"))
             },
         ylab = "Counts",
         xlab = "Gear",
         main = "Gear counts plot (mtcars)")

Output plot

答案 1 :(得分:2)

在excel 2013中,您可以使用图像文件填充图表中的列。右键单击该列,然后从弹出菜单中选择格式数据点。选择油漆桶选项卡,在填充选项下选择图片或纹理填充,然后从文件中插入图片。图像现在覆盖在图表的列上。

相关问题