相关疑难解决方法(0)

在 ggplot2 中自定义“scale_color_gradient2”

我想在我的图像图中使用我自己的特定颜色。我是 ggplot2 的新手,所以从这里查看了它的手册并尝试重复一些内容;但我不知道如何提供我的颜色条,就像我为图形绘图所做的那样。

library(reshape2)
library(ggplot2)

#my specific color list
mycol <- vector(length=512, mode = "numeric")
for (k in 1:256) mycol[k] <- rgb(255, k - 1, k - 1, maxColorValue=255)
for (k in 257:512) mycol[k] <- rgb(511 - (k - 1), 511 - (k - 1), 255, maxColorValue=255)
mycol <- rev(mycol)
ncolors <- length(mycol)

# graphics plot
par(mar = c(5, 13, 1, 6))
image(1:ncol(volcano), 1:nrow(volcano), t(volcano), zlim = c(0, ncolors), col=mycol, axes=FALSE, main="W Matrix", sub = "", xlab= "Components", …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

5
推荐指数
2
解决办法
9357
查看次数

如何在ggplot中更改标签(图例)?

我的代码如下,我想更改ggplot的标签,但R总是提醒我:

Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

ggplot(mat,aes(x=sales,col=type))+
  geom_density()+labels("red_sold","blue_sold","yellow_sold")
Run Code Online (Sandbox Code Playgroud)

math statistics plot r ggplot2

1
推荐指数
2
解决办法
5770
查看次数

标签 统计

ggplot2 ×2

r ×2

math ×1

plot ×1

statistics ×1