r-我的条形图中的图例太大了,甚至没有显示所有的图例,颜色也太相似了



我有一个很大的数据集,我正在尝试创建一个包含国家和年份的堆叠条形图。以下是我现在拥有的:

counts <- table(IMDB$country, IMDB$year)
barplot(counts, main="Movies produced in each country by year",
xlab="Years", col=colorRampPalette(brewer.pal(name="Dark2", n = 8))(15),
legend = rownames(counts))

我如何才能让传说中的所有国家都可见,因为在我的情况下,并不是所有的国家都出现了,而且颜色看起来太相似了,所以我有时无法区分它们?

在开始绘图之前,您需要设置一个自定义的长度和宽度参数。看见?png((或相关的pdf((、svg((等

你最好的调色板选择是那些在色轮上有足够分布以便于区分的调色板。

添加:关于您的示例请求,这里和示例中已经有很多使用"?"的示例。然而

png(filename= "rplotpng.png",width=1000,  height=400, units ="px")
plot(1:30,rep(2,30))
dev.off()
# you will find the output in  your working directory.

最新更新