投稿问答最小化  关闭

万维书刊APP下载

Matlab论文插图绘制模板第125期—特征渲染的三维气泡图

2023/12/20 16:53:29  阅读:79 发布者:

在之前的文章中,分享了很多Matlab三维气泡图的绘制模板:

进一步,再来分享一下特征渲染的三维气泡图。

先来看一下成品效果:

模板中最关键的部分内容:

1. 数据准备

此部分主要是读取原始数据。

% 读取数据

load carsmall.mat

2. 颜色定义

作图不配色就好比做菜不放盐,总让人感觉少些味道。

但颜色搭配比较考验个人审美,需要多加尝试。

这里直接使用TheColor配色工具中的SCI权威配色库:

%% 颜色定义

map = TheColor('sci',2061);

map = flipud(map);

3. 特征渲染的三维气泡图绘制

通过调用bubblechart3’命令,绘制初始特征渲染的三维气泡图。

t = tiledlayout(1,1);

nexttile

b1 = bubblechart3(MPG,Weight,Displacement,Horsepower,Horsepower,...

    'MarkerFaceAlpha',0.4);

bubblesize([5 30])

view(-41,30)

hTitle = title('Bubble3Feature chart');

hXLabel = xlabel('Miles Per Gallon (MPG)');

hYLabel = ylabel('Weight');

hZLabel = zlabel('Displacement');

4. 细节优化

为了插图的美观,对坐标轴细节等进行美化:

% 赋色

colormap(map)

cb = colorbar;

% 坐标区调整

set(gca, 'Box', 'on', ...                                                           % 边框

         'XGrid', 'on', 'YGrid', 'on', 'ZGrid', 'on',...                            % 网格

         'TickDir', 'out', 'TickLength', [.01 .01], ...                             % 刻度

         'XColor', [.1 .1 .1],  'YColor', [.1 .1 .1],'ZColor', [.1 .1 .1])          % 坐标轴颜色

set(gca, 'xlim',[0 50],...

         'zlim',[0 500])

% legend

cb.Label.String = 'Horsepower';

blgd = bubblelegend('Horsepower');

cb.Layout.Tile = 'east';

blgd.Layout.Tile = 'east';

% 字体和字号

set(gca, 'FontName', 'Arial', 'FontSize', 11)

set([hXLabel,hYLabel,hZLabel], 'FontName',  'Arial', 'FontSize', 11)

set(hTitle, 'FontSize', 12, 'FontWeight' , 'bold')

% 背景颜色

set(gcf,'Color',[1 1 1])

设置完毕后,以期刊所需分辨率、格式输出图片。

%% 图片输出

figW = figureWidth;

figH = figureHeight;

set(figureHandle,'PaperUnits',figureUnits);

set(figureHandle,'PaperPosition',[0 0 figW figH]);

fileout = 'test';

print(figureHandle,[fileout,'.png'],'-r300','-dpng');

以上。

转自:“阿昆的科研日常”微信公众号

如有侵权,请联系本站删除!


  • 万维QQ投稿交流群    招募志愿者

    版权所有 Copyright@2009-2015豫ICP证合字09037080号

     纯自助论文投稿平台    E-mail:eshukan@163.com