- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想根据第一幅图中以下彩色点的浓度数据在 xy 平面上创建等值线图。我在每个高度都没有角点,因此我需要将浓度外推到 xy 平面的边缘 (xlim=c(0,335),ylim=c(0,426))。
点的绘图 html 文件可在此处获取:https://leeds365-my.sharepoint.com/:u:/r/personal/cenmk_leeds_ac_uk/Documents/Documents/HECOIRA/Chamber%20CO2%20Experiments/Sensors.html?csf=1&e=HiX8fF
dput(df)
structure(list(Sensor = structure(c(11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 1L, 3L, 4L, 5L, 6L, 8L, 30L, 31L, 32L, 33L, 34L, 35L), .Label = c("N1",
"N2", "N3", "N4", "N5", "N6", "N7", "N8", "N9", "Control", "A1",
"A10", "A11", "A12", "A13", "A14", "A15", "A16", "A17", "A18",
"A19", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "R1",
"R2", "R3", "R4", "R5", "R6"), class = "factor"), calCO2 = c(2237,
2389.5, 2226.5, 2321, 2101.5, 1830.5, 2418, 2356.5, 435, 2345.5,
2376, 2451, 2397, 2466, 2518.5, 2087, 2463, 2256.5, 2345.5, 3506,
2950, 3386, 2511, 2385, 3441, 2473, 2357.5, 2052.5, 2318, 1893.5,
2251), x = c(83.75, 167.5, 167.5, 167.5, 251.25, 167.5, 251.25,
251.25, 0, 83.75, 251.25, 167.5, 251.25, 83.75, 83.75, 83.75,
83.75, 251.25, 167.5, 335, 0, 0, 335, 167.5, 167.5, 167.5, 0,
335, 335, 167.5, 167.5), y = c(213, 319.5, 319.5, 110, 319.5,
213, 110, 110, 356, 213, 319.5, 110, 213, 110, 319.5, 319.5,
110, 213, 213, 0, 0, 426, 426, 426, 0, 213, 213, 70, 213, 426,
0), z = c(155, 50, 155, 155, 155, 226, 50, 155, 178, 50, 50,
50, 50, 155, 50, 155, 50, 155, 50, 0, 0, 0, 0, 0, 0, 0, 130,
50, 120, 130, 130), Type = c("Airnode", "Airnode", "Airnode",
"Airnode", "Airnode", "Airnode", "Airnode", "Airnode", "Airnode",
"Airnode", "Airnode", "Airnode", "Airnode", "Airnode", "Airnode",
"Airnode", "Airnode", "Airnode", "Airnode", "Naveed", "Naveed",
"Naveed", "Naveed", "Naveed", "Naveed", "Rotronic", "Rotronic",
"Rotronic", "Rotronic", "Rotronic", "Rotronic")), .Names = c("Sensor",
"calCO2", "x", "y", "z", "Type"), row.names = c(NA, -31L), class = "data.frame")
require(plotly)
plot_ly(data = subset(df,z==0), x=~x,y=~y, z=~calCO2, type = "contour") %>%
layout(
xaxis = list(range = c(340, 0), autorange = F, autorange="reversed"),
yaxis = list(range = c(0, 430)))
我正在寻找类似的东西。任何帮助将不胜感激。
最佳答案
首先,您必须考虑到 +-30 点不足以获得示例中看到的那些干净的分离层。说了这么多,让我们开始工作吧:
首先,您可以监视数据以猜测这些层的形状。在这里您可以轻松地看到较低的 z 值具有较高的 CO2 值。
require(dplyr)
require(plotly)
require(akima)
require(plotly)
require(zoo)
require(raster)
plot_ly(df, x=~x,y=~y, z=~z, color =~calCO2)
重要的是您必须定义您将拥有的层。这些层必须由整个表面上的值插值制成。所以:
这是代码:
## Define your layers in z range (by hand or use quantiles, percentiles, etc.)
df1 <- subset(df, z >= 0 & z <= 125) #layer between 0 and 150m
df2 <- subset(df, z > 125) #layer between 150 and max
#interpolate values for each layer and for z and co2
z1 <- interp(df1$x, df1$y, df1$z, extrap = TRUE, duplicate = "mean") #interp z layer 1 with spline interp
ifelse(anyNA(z1$z) == TRUE, z1$z[is.na(z1$z)] <- mean(z1$z, na.rm = TRUE), NA) #fill na cells with mean value
z2 <- interp(df2$x, df2$y, df2$z, extrap = TRUE, duplicate = "mean") #interp z layer 2 with spline interp
ifelse(anyNA(z2$z) == TRUE, z2$z[is.na(z2$z)] <- mean(z2$z, na.rm = TRUE), NA) #fill na cells with mean value
c1 <- interp(df1$x, df1$y, df1$calCO2, extrap = F, linear = F, duplicate = "mean") #interp co2 layer 1 with spline interp
ifelse(anyNA(c1$z) == TRUE, c1$z[is.na(c1$z)] <- mean(c1$z, na.rm = TRUE), NA) #fill na cells with mean value
c2 <- interp(df2$x, df2$y, df2$calCO2, extrap = F, linear = F, duplicate = "mean") #interp co2 layer 2 with spline interp
ifelse(anyNA(c2$z) == TRUE, c2$z[is.na(c2$z)] <- mean(c2$z, na.rm = TRUE), NA) #fill na cells with mean value
#THE PLOT
p <- plot_ly(showscale = TRUE) %>%
add_surface(x = z1$x, y = z1$y, z = z1$z, cmin = min(c1$z), cmax = max(c2$z), surfacecolor = c1$z) %>%
add_surface(x = z2$x, y = z2$y, z = z2$z, cmin = min(c1$z), cmax = max(c2$z), surfacecolor = c2$z) %>%
add_trace(data = df, x = ~x, y = ~y, z = ~z, mode = "markers", type = "scatter3d",
marker = list(size = 3.5, color = "red", symbol = 10))%>%
layout(title="Stack Exchange Plot")
p
关于r - 如何在稀疏点之间插入数据以在 R 和plotly 中绘制等高线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54726853/
我试图理解 findContours 的输出基于 this one 等教程和文档。我想知道为什么我得到我得到的输出。我有一个中间有一个正方形的 jpeg img,我的目标是找到正方形并为其着色(只是为
我有一组数据,其中包含 x 和 y 坐标以及每个坐标的计算值。网格是不规则的,所以现在我一直在创建一个散点图并将值分成多个箱子,以显示为下面链接中 img 上的等高线。 http://i.stack.
这个问题在这里已经有了答案: Test if a numpy array is a member of a list of numpy arrays, and remove it from the
我有一个存储为栅格的高程图。我想将平滑的“vector ”曲线拟合到恒定高度的轮廓。在我的应用程序中,数据实际上是地理海拔,但问题可以推广到两个变量的任何函数。 如果有帮助,我可以生成另一个具有抗锯齿
我想生成一个带有颜色条的等高线图/热图,然后添加一个注释框。这个数字很丑,但得到了我想要的: add_subplot() 是不够的。如果我尝试将所有内容都放在同一个子图中,则该框会被遮盖。我可以通过使
我正在尝试使用属于 ROOT 的 Minuit2 最小化器为具有物理限制的参数生成等高线图数据分析框架。不幸的是,当我尝试生成等高线图时,Minuit2 似乎有意将参数漂移到超出其限制的区域: >>>
我的目标是这种效果:(仅水平轮廓线): 我确实找到了 this example ,但是它会创建水平 和 垂直轮廓线。我无法完全理解如何调用 fwidth()正在生成线条。 uniform float
大家好,我是编程新手,我正在尝试做一些可能非常明显的事情,但对于我来说,我无法弄明白。我有一系列 x、y、z 数据(在我的例子中,对应于距离、深度和 pH 值)。我想使用 matplotlib 在 x
我是一名优秀的程序员,十分优秀!