juyter显示决策树图形_python – 在Jupyter笔记本中绘制交互式决策...

使用Jupyter Notebook中的d3js更新了可折叠图形的答案

在笔记本电脑中启动第一个单元

%%html

.node circle {

cursor: pointer;

stroke: #3182bd;

stroke-width: 1.5px;

}

.node text {

font: 10px sans-serif;

pointer-events: none;

text-anchor: middle;

}

line.link {

fill: none;

stroke: #9ecae1;

stroke-width: 1.5px;

}

笔记本电脑中的第一个电池结束

在笔记本中开始第二个单元格

%%javascript

// We load the d3.js library from the Web.

require.config({paths:

{d3: "http://d3js.org/d3.v3.min"}});

require(["d3"], function(d3) {

// The code in this block is executed when the

// d3.js library has been loaded.

// First, we specify the size of the canvas

// containing the visualization (size of the

//

element).

var width = 960,

height = 500,

root;

// We create a color scale.

var color = d3.scale.category10();

// We create a force-directed dynamic graph layout.

// var force = d3.layout.force()

// .charge(-120)

// .linkDistance(30)

// .size([width, height]);

var force = d3.layout.force()

.linkDistance(80)

.charge(-120)

.gravity(.05)

.size([width, height])

.on("tick", tick);

var svg = d3.select("body").append("svg")

.attr("width", width)

.attr("height", height);

var link = svg.selectAll(".link"),

node = svg.selectAll(".node&#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值