D3 二维图表的绘制系列(十四)气泡图

D3系列第四弹——绘制气泡图 温故而知新 阅读详情

上一篇: 多符号散点图 https://blog.youkuaiyun.com/zjw_python/article/details/98483989

下一篇: 雷达图 https://blog.youkuaiyun.com/zjw_python/article/details/98486655

代码结构和初始化画布的Chart对象介绍,请先看 https://blog.youkuaiyun.com/zjw_python/article/details/98182540

本图完整的源码地址: https://github.com/zjw666/D3_demo/tree/master/src/scatterChart/bubbleChart

1 图表效果

在这里插入图片描述

2 数据

x,y,size
24,12,64
39,20,14
78,15,67
15,80,34
36,70,14
7,11,64
36,13,34
34,89,74
9,95,6
72,35,25
26,65,80
16,36,10
99,65,45
46,78,65
85,42,55
32,14,20
43,12,31
73,95,8
8,6,16
81,62,11

3 关键代码

导入数据

d3.csv('./data.csv', function(d){
   
   
    return {
   
   
        x: +d.x,
        y: +d.y,
        r: +d.size
    };
}).then(function(data){
   
   
.....

一些样式参数配置

const config = {
   
   
        margins: {
   
   top: 80, left: 80, bottom: 50, right: 80},
        textColor: 'black',
        gridColor: 'gray',
        ShowGridX: [10, 20, 30, 40, 50, 60, 70 ,80, 90, 100],
        ShowGridY: [10, 20, 30, 40, 50, 60, 70 ,80, 90, 100],
        title: '气泡图',
        pointMaxSize: 20,
        hoverColor: 'white',
        animateDuration: 1000,
        pointCenterColor: 'white',
        pointEdgeColor: chart._colors(0)
    }

尺度转换,气泡图相比基础散点图,新增了一个数据点的大小作为新的维度

/* ----------------------------尺度转换------------------------  */
    chart.scaleX = d3.scaleLinear()
                    .domain([0, Math.ceil(d3.max(data, (d) => d.x)/10)*10])
                    .range([0, chart.getBodyWidth()]);
    
    chart.scaleY = d3.scaleLinear()
                    .domain([0, Math.ceil(d3.max(data, (d) => d.y)/10)*10])
                    .range([chart.getBodyHeight(), 0]);
    
    chart.scaleSize = d3.scaleLinear()
                        .
d3.js—— 绘制二维数组的动态图表 在绘制二维数组的动态图表之前,我们先来理一下思路: 1、我们需要绘制一张图表; 2、这张图表的数据来源是二维数组; 3、这张图表有动态效果。 那么,我们一步一步来: 首先,我们来随意写一串二维数组,确定数据来源:var data =[[1993,10],[1998,20],[2002,25],[2007,30],[2010,50],[2015,80],[2016,90]] 然后,我 阅读详情

相关推荐

Echarts气泡图(相邻效果,气泡之间不叠加)

效果图 借助Echarts中提供的样例完成,官网样例可自行前往 官网链接放下面啦!! Examples - Apache ECharts 使用版本 完整代码如下 <!-- d3js 气泡图 --> <template> <div id="bubble" style="width: 500px;height:500px"></div> </template> <script> import * as echarts from

m0_67401851的博客 2318

D3 二维图表的绘制系列(一)介绍

1 介绍 D3 (或者叫 D3.js )是一个基于 web 标准的 JavaScript 可视化库. D3 可以借助 SVG, Canvas 以及HTML 将你的数据生动的展现出来. D3 结合了强大的可视化交互技术以及数据驱动 DOM 的技术,让你可以借助于现代浏览器的强大功能自由的对数据进行可视化 学习了d3一个多月,通过绘制一些简单的二维图表,总算入门了d3。强烈推荐《D3数据可视化实战...

zjw_python的博客 6万+

react-bubble-chart-d3:使用 D3 React气泡图

React气泡图-d3 ReactJS 组件使用 d3 将数据显示为气泡图。 预习 一般用法 正如您在中看到的那样,为了使用我们需要将其导入的组件: import BubbleChart from &#39;@weknow/react-bubble-chart-d3&#39; ; 然后,在 render 方法中,我们可以像这样调用它: bubbleClick = ( label ) => { console . log ( "Custom bubble click func" ) } legendClick = ( label ) => { console . log ( "Customer legend click func" ) } < BubbleChart graph = { { zoom : 1.1 , offsetX : - 0.05 , off

D3.js实现散点图和气泡图的方法详解

将会给大家介绍了另外两种可视化图表,利用D3.js实现散点图和气泡图,文章通过多个方面介绍的非常详细,下面来一起看看吧。

【DDSCAT——离散偶极近似仿真程序04】参数理解和模型设计

在这一部分,我们开始理解DDSCAT程序设计中的一些参数问题。 承接第二部分内容中的ddscat.par文件,我们来聊一聊偶极子、实际体积、有效半径等关键词。 一、偶极子点阵 手册中说,我们需要设计模型(target/目标),它是有偶极子点阵组成的。偶极子,顾名思义,是由一对电荷组成的,但我们不用设计一对,我们设计一个点就行,...

XD_Yangf的博客 7552

自抗扰控制(ADRC)原理与MATLAB实现详解

自抗扰控制(ADRC)是一种先进的鲁棒控制策略,其核心在于通过扩张状态观测器(ESO)实时估计并补偿系统总扰动。相比传统PID控制,ADRC不依赖精确数学模型,特别适合处理非线性、时变系统。从控制原理看,ADRC将系统内部动态和外部扰动统一建模,通过带宽参数化方法实现快速响应与强抗扰能力。在工程实践中,ADRC已成功应用于无人机飞控、伺服系统等场景,MATLAB仿真显示其上升时间可比PID提升46%,抗扰动恢复时间缩短60%。典型实现包含ESO设计、扰动补偿和PD控制三部分,参数整定遵循ω₀=3~5倍系统带

weixin_33585822的博客 95

3、基于视觉的智能分拣机:原理、算法与应用

本文介绍了一种基于视觉的智能分拣系统,利用树莓派、相机模块和多种检测算法实现低成本、高精度的物体分拣。系统支持颜色、形状和尺寸三种检测方式,准确率达99%,广泛适用于制造业、农业和物流等领域。文章详细阐述了各检测算法原理、测试结果及系统优化方向,并探讨了其实际应用案例与未来发展前景。

mqtt6iot的博客 237

【Zephyr存储专题】09_LittleFs文件系统操作

本文档旨在为开发者介绍Zephyr下Littlef's文件系统相关配置使用指南

zero的博客 3246

辉芒微教程第七篇《PWM与PWM3调节LED灯的亮度》

这个其实就是PR3L = 128设置的,由于我们刚刚寄存器设置了8位模式,其设置的范围就是0-255,而128/255≈50%左右,因此PR3L就是我们的占空比调节的寄存器,我们可以通过它来调节占空比,大家可以试试它占空比设置10%,30%,60%来看看它的不同效果,灯的亮度是肯定不一样的,如果有条件的朋友,可以购买一款逻辑分析仪去看他的占空比。平平无期的这个东西有什么东东用,貌似是没什么用,只是一个概念而已,是不是不同设备可以设置1秒,3秒,10秒的周期就行?但是它占空比为什么是50%,怎么得来的?

qq_41809823的博客 827

PCL K4PCS算法实现点云粗配准【2026最新版】

K4PCS算法实现点云粗配准。博客长期更新,本文最近一次更新时间为:2026年5月4日。

点云侠的博客 42万+

基于Simulink的超级电容与锂电池混合储能协调控制仿真

摘要:本文介绍基于Simulink的光伏-混合储能系统(HESS)建模与仿真方法,通过超级电容和锂电池的协同控制实现功率平抑。系统采用直流耦合架构,利用一阶低通滤波法将总功率分解为低频(锂电池承担)和高频分量(超级电容承担),并设计SOC自平衡机制维持超级电容工作点。仿真结果表明,该方案可使锂电池电流波动降低62%,光伏功率波动率降至7.5%,有效延长电池寿命。文章详细展示了从主电路搭建、功率分配到闭环控制的完整实现步骤,为新能源系统储能优化提供实用参考。

amy_mhd的博客 136

前端Three.js面试题及参考答案

渲染循环(Render Loop)是 Three.js 中一个非常重要的概念,它是一个不断重复执行的过程,用于更新和渲染 3D 场景。在每次循环中,渲染循环会更新场景中的对象状态,如位置、旋转、缩放等,然后使用渲染器将更新后的场景渲染成 2D 图像显示在屏幕上。通过不断地重复这个过程,就可以实现动画效果。渲染循环的核心作用是确保场景能够实时更新,给用户带来流畅的视觉体验。如果没有渲染循环,场景将是静态的,不会有任何变化。只有通过不断地更新和渲染,才能让场景中的对象动起来,实现各种动画效果。

大模型大数据攻城狮的专栏 2722

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

上一篇: D3 二维图表的绘制系列(十一)南丁格尔图
下一篇: D3 二维图表的绘制系列(十五)雷达图
PAT-python-zjw
博客等级 码龄10年 381粉丝 408原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值