我想知道是否有可能平滑情节或使其更好,因为现在像素太大了.
library(ggplot2)
library(reshape2)
# plot2d = melt(c)
plot2d = melt(matrix(rnorm(20), 5)) # fake data
names(plot2d) <- c("x", "y", "z")
v <- ggplot(plot2d, aes(x, y, z = z))
v + geom_tile(aes(fill = z)) +
scale_alpha_continuous(limits=c(start.point, end.point)) +
scale_fill_gradient2('TYYYT',low="green", mid = "white", high="red")
Run Code Online (Sandbox Code Playgroud)
我想知道是否有可能将 linearGradient 设为across (from top to bottom)直线,而不是下面的示例中渐变along (from left to right)为直线的示例。
<svg xmlns="http://www.w3.org/2000/svg" version="1">
<defs>
<linearGradient id="e" x1="40" y1="210" x2="460" y2="210" gradientUnits="userSpaceOnUse">
<stop stop-color="steelblue" offset="0" />
<stop stop-color="red" offset="1" />
</linearGradient>
</defs>
<line x1="40" y1="210" x2="460" y2="210" stroke="url(#e)" stroke-width="30" />
</svg>
Run Code Online (Sandbox Code Playgroud)
更改 y 坐标对于未旋转的线非常有效,linearGradient 现在穿过(从上到下)线:
<svg xmlns="http://www.w3.org/2000/svg" version="1">
<defs>
<linearGradient id="e" x1="40" y1="195" x2="40" y2="225" gradientUnits="userSpaceOnUse">
<stop stop-color="steelblue" offset="0" />
<stop stop-color="red" offset="1" />
</linearGradient>
</defs>
<line x1="40" y1="210" x2="460" y2="210" stroke="url(#e)" stroke-width="30"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
但不适用于旋转: …
我试图用四舍五入到小数点后两位的相同数字替换字符串中的所有浮点数。例如"Hello23.898445World1.12212"应该变成"Hello23.90World1.12".
我可能会找到数字的位置,gregexpr("[[:digit:]]+\\.*[[:digit:]]*", str)[[1]]但不知道如何用圆形原件替换它们。