Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在ggplot2中设置颜色轴限制_R_Matlab_Ggplot2_Colors_Heatmap - Fatal编程技术网

R 在ggplot2中设置颜色轴限制

R 在ggplot2中设置颜色轴限制,r,matlab,ggplot2,colors,heatmap,R,Matlab,Ggplot2,Colors,Heatmap,我试图绘制叶绿素荧光与深度和时间的热图。我的工作还不错,但我正在努力提高我的颜色对比度。我用下面的代码生成我的热图 ggplot(subset(ctdamotInt2, variable == 'fluorescence'), aes(time, depth)) + geom_tile(aes(fill = log10(value))) + scale_y_reverse(limits = c(110, 0)) + scale_x_time(limits = c(min(subset(ctdam

我试图绘制叶绿素荧光与深度和时间的热图。我的工作还不错,但我正在努力提高我的颜色对比度。我用下面的代码生成我的热图

ggplot(subset(ctdamotInt2, variable == 'fluorescence'), aes(time, depth)) +
geom_tile(aes(fill = log10(value))) + scale_y_reverse(limits = c(110, 0)) +
scale_x_time(limits = c(min(subset(ctdamot, variable == 'nh4')$time) - 2 * 60^2, max(subset(ctdamot, variable == 'nh4')$time) + 2* 60^2)) +
geom_point(data = samplesCTD, aes( x = time, y = depth)) +
scale_fill_gradient2(low = "blue", mid = "white", high = "green")

一般来说,我发现深绿色基本上从未被利用过,因此我的热图最终看起来被冲掉了,在叶绿素荧光最亮的地方无法很好地沟通。如果我在matlab中工作,我会通过设置

 caxis([-1 0.4])
这会将0.4以上的所有值设置为最大绿色值。你不可能分辨出真正高的值的相对差异,但你至少能够更好地了解构成大部分绘图的中间值的相对差异。有什么建议可以让我的这块地更大的比例是绿色的吗?我想我可以手动重新缩放输入值,但如果有更好的方法,我宁愿不这样做

编辑:应Mike H的要求

dput(head(ctdamotInt2,100))

    structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("temperature",  "salinity",
    "fluorescence", "oxygen", "nh4"), class = "factor"), 
        depth = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), time = structure(c(1482764087, 
    1482767687, 1482771287, 1482774887, 1482778487, 1482782087, 
    1482785687, 1482789287, 1482792887, 1482796487, 1482800087, 
    1482803687, 1482807287, 1482810887, 1482814487, 1482818087, 
    1482821687, 1482825287, 1482828887, 1482832487, 1482836087, 
    1482839687, 1482843287, 1482846887, 1482850487, 1482854087, 
    1482857687, 1482861287, 1482864887, 1482868487, 1482872087, 
    1482875687, 1482879287, 1482882887, 1482886487, 1482890087, 
    1482893687, 1482897287, 1482900887, 1482904487, 1482908087, 
    1482911687, 1482915287, 1482918887, 1482922487, 1482926087, 
    1482929687, 1482933287, 1482936887, 1482940487, 1482944087, 
    1482947687, 1482951287, 1482954887, 1482958487, 1482962087, 
    1482965687, 1482969287, 1482972887, 1482976487, 1482980087, 
    1482983687, 1482987287, 1482990887, 1482994487, 1482998087, 
    1483001687, 1483005287, 1483008887, 1483012487, 1483016087, 
    1483019687, 1483023287, 1483026887, 1483030487, 1483034087, 
    1483037687, 1483041287, 1483044887, 1483048487, 1483052087, 
    1483055687, 1483059287, 1483062887, 1483066487, 1483070087, 
    1483073687, 1483077287, 1483080887, 1483084487, 1483088087, 
    1483091687, 1483095287, 1483098887, 1483102487, 1483106087, 
    1483109687, 1483113287, 1483116887, 1483120487), class = c("POSIXct", 
    "POSIXt")), value = c(27.3483, 27.3483, 27.3483, 27.3483, 
    27.4404348314607, 27.5325696629213, 27.624704494382, 27.7168393258427, 
    27.8089741573034, 27.901108988764, 27.9932438202247, 28.0853786516854, 
    28.1006709677419, 28.1151870967742, 28.1297032258065, 28.1602961677656, 
    28.3392342471866, 28.5181723266075, 28.6971104060285, 28.8760484854494, 
    29.0549865648704, 29.1744078768732, 29.2330425521923, 29.2916772275114, 
    29.3503119028306, 29.4089465781497, 29.4675812534688, 29.5262159287879, 
    29.5233725024786, 29.5198033650201, 29.5162342275617, 29.5126650901032, 
    29.5090959526448, 29.5055268151863, 29.5019576777279, 29.4983885402694, 
    29.494819402811, 29.4392079391567, 29.3230472306014, 29.2068865220461, 
    29.0907258134908, 28.9745651049355, 28.8584043963802, 28.7422436878249, 
    28.6260829792696, 28.5099222707143, 28.5396702257581, 28.6045126836247, 
    28.6693551414913, 28.734197599358, 28.7990400572246, 28.8638825150912, 
    28.9287249729579, 28.9935674308245, 29.0584098886912, 29.1232523465578, 
    29.1880948044244, 29.2529372622911, 29.3177797201577, 29.3826221780244, 
    29.447464635891, 29.5123070937576, 29.4047436790674, 29.2746548739928, 
    29.1445660689182, 29.0144772638436, 28.8843884587691, 28.7542996536945, 
    28.6242108486199, 28.4941220435453, 28.4440444629526, 28.4161338799902, 
    28.3882232970279, 28.3603127140655, 28.3324021311032, 28.3044915481409, 
    28.2765809651785, 28.2486703822162, 28.2207597992539, 28.1928492162915, 
    28.1649386333292, 28.1370280503668, 28.1091174674045, 28.0812068844422, 
    28.0532963014798, 28.0253857185175, 27.9974751355552, 27.9695645525928, 
    27.9416539696305, 27.9137433866682, 27.8858328037058, 27.8579222207435, 
    27.8300116377811, 27.8021010548188, 27.7741904718565, 27.7462798888941, 
    27.7183693059318, 27.6904587229695, 27.6625481400071, 27.6346375570448
    )), .Names = c("variable", "depth", "time", "value"), row.names = c(NA,  100L), class = "data.frame")

您可以发布一个
dput(ctdamotInt2)
?或者如果它真的很大,可能只是
dput(head(ctdamotin2100))
您可以尝试
scale\u fill\u gradientn
values=rescale(…)
,如前所述,例如,这看起来很有希望Henrik。我将在通过重新缩放正确配置颜色后进行更新。您的数据样本(
dput()
result)仅包含变量
temperature
的数据,而不包含
fluoresence
的数据。所以这个情节无法复制。