如何突出显示R中的水平图中的最小值?

时间:2018-04-14 19:56:26

标签: r levelplot

如何将385 * 373水平图的十个最小值网格点突出显示为黑点? 我有索引以及十个最小网格点的坐标。我最好使用idexes ......

我有以下等级图显示欧洲气温(Z),X和Y分别为经度和纬度。

sqllocaldb info

还有一个问题:如何使用与基础数据相同的投影类型添加国家/地区轮廓?我之前在另一个函数

中尝试过
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
 if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
  $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
  Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
  Exit
 }
}


[CmdletBinding()]


$Name = "LocalDBAlias"
$SQLServerName = "mssqllocaldb"

sqllocaldb start mssqllocaldb

$ThePipe = ((sqllocaldb info mssqllocaldb | Select-String -Pattern "np") -split ":")[2]

$hive = "localmachine"

$key = "SOFTWARE\\Microsoft\\MSSQLServer\\Client\\ConnectTo"
$key32 = "SOFTWARE\\WOW6432Node\\Microsoft\\MSSQLServer\\Client\\ConnectTo"

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]$hive, $env:COMPUTERNAME)


$subkey = $reg.OpenSubKey($key, $true)
$subkey32 = $reg.OpenSubKey($key32, $true)


$res = $subkey.GetValue($Name)
$res32 = $subkey32.GetValue($Name)

$CurrentPipe = ($res -split ",")[1]


if ($CurrentPipe -eq $ThePipe)
{
    Write-Output "The $Name alias' named pipes match the current instance of mssqllocaldb."
}
else 
{
    $subkey.SetValue($Name,"DBNMPNTW,$ThePipe")
    $subkey32.SetValue($Name,"DBNMPNTW,$ThePipe")
    Write-Output "The $Name alias for MSSQLLocalDB has been set."
}


$reg.Close()

国家轮廓图似乎有一个完全不同的预测。但是,我现在要为levelplot(Z ~ X*Y, data=data , xlab="X" , col.regions = heat.colors(100)) 执行此操作。 我非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

lattice图与基础图不同。因此,使用points不起作用。但是有替代功能。这是一种方法:

x    <- seq(-10, 10, length.out = 100)
y    <- seq(-10, 10, length.out = 100)
z    <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- cbind(expand.grid(x=x, y=y), z)

minimum <- grid[which.min(grid$z),]

levelplot(z ~ x * y, grid, panel = function(...) {
            panel.levelplot(...)
            panel.points(x = minimum$x, y = minimum$y, pch = "x", cex  =2)
          })

我们基本上是在panel参数内构建情节。

enter image description here