簡體   English   中英

傾斜軸2D圖,其中xy軸成60度而不是90度

[英]tilted axis 2D plot where x y axis make 60 degree rather than 90

我想像下面那樣在六角形格子中繪制分布。

我想將此數據顯示為2D色彩圖或條形圖。 有誰知道如何做到這一點? 我熟悉八度,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中使用patch的解決方案。

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

這產生了 在此處輸入圖片說明

如果需要更改配色方案,請閱讀文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM