最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to get a transparent background in Matlab for wordcloud - Stack Overflow

programmeradmin0浏览0评论

I am unable to get a transparent background in this MWE file; no errors. The procedure works fine for other types of Matlab plotting function

    fileName = 'C-13.tex'; % Input file name
    text = ' this this this a  is a test';
    text = lower(text);
    words = split(text);
    [uniqueWords, ~, idx] = unique(words);
    wordCounts = accumarray(idx, 1);
    wordTable = table(uniqueWords, wordCounts, 'VariableNames', {'Word', 'Frequency'});
    wordTable = sortrows(wordTable, 'Frequency', 'descend');
    topWordCount = 75; % Keep top 75 words
    wordTable = wordTable(1:min(topWordCount, height(wordTable)), :);
    hf = figure;
    wc = wordcloud(wordTable.Word, wordTable.Frequency);
    orangeColor = [1.0, 0.5, 0.0]; % Bright orange
    colorMap = repmat(orangeColor, numel(wc.WordData), 1);
    wc.Color = colorMap;
    %set(gca,'color', 'none');
    set(gcf, 'color', 'None');
    exportgraphics(hf,'out.pdf','BackgroundColor','none','ContentType','vector')
发布评论

评论列表(0)

  1. 暂无评论