小编Ale*_*sky的帖子

光滑的2D表面

我想知道是否有可能平滑情节或使其更好,因为现在像素太大了.

  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)

在此输入图像描述

r smooth ggplot2

10
推荐指数
1
解决办法
1650
查看次数

SVG 线的线性渐变

我想知道是否有可能将 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)

在此处输入图片说明

但不适用于旋转: …

svg line linear-gradients

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

舍入字符串中的所有浮点数

我试图用四舍五入到小数点后两位的相同数字替换字符串中的所有浮点数。例如"Hello23.898445World1.12212"应该变成"Hello23.90World1.12".

我可能会找到数字的位置,gregexpr("[[:digit:]]+\\.*[[:digit:]]*", str)[[1]]但不知道如何用圆形原件替换它们。

replace r

5
推荐指数
1
解决办法
1018
查看次数

标签 统计

r ×2

ggplot2 ×1

line ×1

linear-gradients ×1

replace ×1

smooth ×1

svg ×1