我有一个3行乘5列的facet plot.每行显示分布在不同范围内的数据.为了正确显示我的数据以便显示所有内容,我没有设置y轴限制.
这是我的代码:
require(reshape2)
library(ggplot2)
library(RColorBrewer)
fileName = paste("./data_test.csv", sep = "")
## data available here: https://dl.dropboxusercontent.com/u/73950/data_test.csv
mydata = read.csv(fileName,sep=",", header=TRUE)
dataM = melt(mydata,c("id"))
dataM = cbind(dataM,
colsplit(dataM$variable,
pattern = "_",
names = c("Network_model", "order", "category")))
dataM$variable <- NULL
dataM <- dcast(dataM, ... ~ category, value.var = "value")
dataM$minCut <- NULL
dataM$nbr_communities <- NULL
dataM$mean_community_size <- NULL
dataM$density <- NULL
my_palette <- colorRampPalette(rev(brewer.pal(11, "Spectral")))
dataM = melt(dataM, id.vars = c("Network_model", "order", "nodesRemoved", "id"))
my_palette = c(brewer.pal(5, "Blues")[c(4)], brewer.pal(5, "Set1")[c(3)])
ggplot(dataM, …Run Code Online (Sandbox Code Playgroud) 这里有一个简单的Lua问题:如何查找给定表中最小或最大数字的索引或键.
math.max/ math.min仅给出实际的最大或最小数量,而不是密钥.
在 Python 中(我没有检查 R),Igraph 告诉我图 G 没有使用 G.is_connected() 连接,而 Networkx 告诉我它使用 nx.is_connected(G) 连接。
知道我的图表,我知道 networkx 是正确的。
某处是否存在已知错误,或者两个包对连通图的定义不同?
事实上,我想知道我的图是否从图中的任何顶点到任何其他顶点都有一条路径连接。
如何用 igraph 做到这一点?
这是我的代码:
from igraph import *
import networkx as nx
(read_a_graph_and_put_it_in_G)
G = G.to_undirected()
print nx.is_connected(G)
adjG = nx.to_numpy_matrix(G.to_undirected())
G = Graph.Adjacency(adjG.tolist())
G.to_undirected()
print G.is_connected()
Run Code Online (Sandbox Code Playgroud)
第一次打印给出 TRUE,第二次给出 FALSE
我正在使用这个R脚本:
tableau <- read.table(
text =
"Net B C D E.(e) F.(f)
a 1.88 0.15 0.60 10.00 90.00
b 2.05 0.23 0.51 55.00 80.00
c 2.09 0.29 0.40 58.00 88.00
d 2.07 0.52 0.36 80.00 84.00
e 2.13 0.30 0.27 7.00 90.00",
header = TRUE)
library(plyr)
library(reshape)
library(ggplot2)
library(scales)
tableau.m <- melt(tableau)
tableau.m <- ddply(tableau.m, .(variable), transform, rescale = rescale(value))
(p <- ggplot(tableau.m, aes(variable, Net)) +
geom_tile(aes(fill = rescale), colour = "white") +
scale_fill_gradient(low = "white", high = "steelblue"))
base_size …Run Code Online (Sandbox Code Playgroud) 我试图找到一个点的距离(在4维中,这里只显示2个)(图中的任何彩色十字)到假定的帕累托边界(黑线).该线代表优化过程中最佳的Pareto前沿表示.
Pareto = [[0.3875575798354123, -2.4122340425531914], [0.37707675586149786, -2.398936170212766], [0.38176077842761763, -2.4069148936170213], [0.4080534133844003, -2.4914285714285715], [0.35963459448268725, -2.3631532329495126], [0.34395217638838566, -2.3579931972789114], [0.32203302106516224, -2.344858156028369], [0.36742404637441123, -2.3886054421768708], [0.40461156254852226, -2.4141156462585034], [0.36387868122767975, -2.375], [0.3393199109776927, -2.348404255319149]]
Run Code Online (Sandbox Code Playgroud)
现在,我计算从任何一点到帕累托边境的距离,如下所示:
def dominates(row, rowCandidate):
return all(r >= rc for r, rc in zip(row, rowCandidate))
def dist2Pareto(pareto,candidate):
listDist = []
dominateN = 0
dominatePoss = 0
if len(pareto) >= 2:
for i in pareto:
if i != candidate:
dominatePoss += 1
dominate = dominates(candidate,i)
if dominate == True:
dominateN += 1
listDist.append(np.linalg.norm(np.array(i)-np.array(candidate)))
listDist.sort()
if dominateN == …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Bootstrap-CSS和水平显示单选按钮Flask-WTForms.据我所知,我需要使用Bootstrap类class_="radio-inline"来实现这一目标.我试过了,我得到的就是这个:
其中,单选按钮是垂直组织的,令人沮丧.
Flask WTForm代码:
from flask.ext.wtf import Form
import csv
import os
import buildHome as bh
from wtforms import TextField, RadioField, TextAreaField, SubmitField, validators, BooleanField
class ContactForm(Form):
firstName = TextField("First name", [validators.Required("Please enter your first name.")])
lastName = TextField("Last name", [validators.Required("Please enter your last name.")])
#name = TextField("Name", [validators.Required("Please enter your name.")])
email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")])
node_1 = BooleanField("Joan Johnson (Buckridge Inc)")
direction_1 = RadioField('', …Run Code Online (Sandbox Code Playgroud) 我试图在大图上找到一个复杂且耗时的多目标优化.
这就是问题所在:我想找到一组n个顶点(n是常数,比如100)和m个边(m可以改变),其中一组度量被优化:
我最好的猜测是选择GA.我对遗传算法不太熟悉,但我可以花一点时间学习基础知识.从我到目前为止所读到的内容来看,我需要这样做:
如果是,那就完美了.如果不:
现在,我通常使用Python进行我的小实验.DEAP(https://code.google.com/p/deap/)可以帮我解决这个问题吗?如果是这样,我还有很多问题(特别是关于交叉和变异的步骤),但简而言之:步骤(在Python中,使用DEAP)是否足够容易在这里解释或总结?
如果需要,我可以尝试和详细说明.干杯.
我阅读了很多关于计算图形编辑距离(GED)或其他图形相似性度量(例如http://goo.gl/gmDMgA)的理论,但我没有找到完成这种计算的工具.
是否有编程库或软件可以计算图形编辑距离,或者,在两个图形之间再次计算任何其他图形相似性度量?
我需要取一个脚本中设置的布尔值(放入一个名为“bouclier”的变量中)来启用或禁用游戏对象。
变量位于游戏对象 Player 中(此处右下角):
我需要启用或禁用此游戏对象(“Bouclier01”):
为此,我将脚本附加到游戏对象“Bouclier01”。这里是:
using UnityEngine;
using System.Collections;
public class ShowBouclier : MonoBehaviour {
public GameObject Bouclier01;
public bool bouclier;
// Use this for initialization
void Start () {
Bouclier01 = Bouclier01.GetComponent<GameObject>();
}
// Update is called once per frame
void Update () {
Bouclier01.enabled = false;
if (bouclier == true) {
Bouclier01.enabled = true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我一定遗漏了一些东西,因为这会出现以下错误消息:
知道如何正确完成此操作吗?
我正在尝试在 Mac 上安装带有 PostGIS 扩展的 PostgreSQL。安装分为两部分:1) PostgreSQL 和 2) PostGIS 通过堆栈构建器。第一阶段很顺利,但第二阶段在安装PostGIS开始时返回以下错误:
我也尝试使用最新版本的 PostgreSQL(版本 12)安装它,但出现相同的错误。知道这里发生了什么吗?