2024-05-31 23:15:50 发布
网友
我想画一个六边形格子的分布,如下所示。在
我想用二维彩色图或条形图来表示这些数据。有人知道怎么做吗?我熟悉octave,python,gnuplot,excel,matlab。在
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
这是一个在MATLAB中使用^{}的解决方案。在
data = cellfun(@(x) textscan(x, '%f')', importdata('data.txt', sprintf('\n'))); rowLen = cellfun(@numel, data); nPoints = sum(rowLen); centerCells = arrayfun(@(l,r) [(-l+1:2:l-1)'*sin(pi/3) -r*1.5*ones(l,1)], ... rowLen', 1:numel(rowLen), 'UniformOutput', false); centers = vertcat(centerCells{:}); hx = linspace(0,2*pi,7)'; vertices = reshape(... bsxfun(@plus, permute(sin([hx pi/2+hx]), [1 3 2]), ... permute(centers, [3 1 2])), 7 * nPoints, 2); faces = reshape(1:7*nPoints, 7, nPoints)'; colorData = vertcat(data{:}); patch('Vertices', vertices, 'Faces', faces, ... 'FaceColor', 'flat', 'FaceVertexCData', colorData); axis equal
这就产生了
如果需要更改配色方案,请阅读documentation。在
这是一个在MATLAB中使用^{} 的解决方案。在
这就产生了
如果需要更改配色方案,请阅读documentation。在
相关问题 更多 >
编程相关推荐