Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw Rain Cloud Map by Matlab

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to draw rain cloud map by Matlab". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to draw a rain cloud map by Matlab".

Introduction

Two code templates are written to draw horizontal and vertical cloud and rain pictures. Cloud and rain pictures are actually templates that separate violin pictures. Those who want to get violin drawing functions can see here: sample code for drawing violin pictures based on Matlab

When the latter two templates are used, you only need to change the data, color and the name of each category. The effect of the rain cloud map is as follows:

Horizontal rain cloud picture function rainCloudsTMPL1% @ author: slandarer% put your data here = = X1 = [normrnd (8mai 4pjing1120), normrnd (5pyrus 2pyrs 1pyrus 25)]; X2 = [normrnd (2.5pyrus 3pyrs 1pyrs 75), normrnd (6mie 4pines 1mons 25s), normrnd (15pals 1mons 1100)]; X3 = [normrnd (4pens 3pens 1pals 40), normrnd (3pas 4pens 1pens 25)]; X4 = [normrnd (4p3pens 140s), normrnd (2jue 4jors 1jors 75)]; dataCell= {X1rem X2ref X2rem X3LJI} % put the data into the cell array, if there is too much data in a writable loop, put it in the dataName= {'A 'Achievement Magistracy, the name of each data class, but the empty% color list colorList= [0.9294 0.7569 0.5059 0.9176 0.5569 0.4627 0.7020 0.5451 0.4863 0.4314 0.5490] % = classNum=length (dataCell); if size (colorList,1) = = 0 colorList=repmat ([130170172]. / 255, [classNum,1]); else colorList=repmat (colorList, [ceil (classNum/size (colorList,1)), 1]); endif isempty (dataName) for i=1:classNum dataName {I} = ['class',num2str (I)]; endend% coordinate region modifies hold onax=gca;ax.YLim= [1Comp2 classNumeric 2PUB3]; ax.YTick=1:classNum;ax.LineWidth=1.2 Ax.YTickLabels=dataName (end:-1:1); ax.FontSize=14;rate=3.5;% to draw rain cloud map for i=1:classNum tX=dataCell {I}; tX=tX (:); [FMagee Xi] = ksdensity (tX);% Ridge map patchCell (I) = fill ([Xi (1), Xi,Xi (end)], 0.2 + [0meme Fjie 0]. * rate+ (classNum+1-i). * ones (1dint (F) + 2), ColorList (iPermian:), 'EdgeColor', [0JEI 0],' FaceAlpha',0.8,'LineWidth',1.2);% other data acquisition qt25=quantile (tX,0.25);% lower quartile qt75=quantile (tX,0.75);% upper quartile med=median (tX);% median outliBool=isoutlier (tX,'quartiles');% outlier nX=tX (~ outliBool) % 95% confidence to draw box chart plot ([min (nX), max (nX)], [(classNum+1-i), (classNum+1-i)], 'kang Zhenzhengli lineWidthyard 1.2); fill ([qt25,qt25,qt75,qt75], (classNum+1-i) + [- 11-1]. * 0.12 EdgeColor', colorList (igrad:),' EdgeColor', [000]) Plot ([med,med], [(classNum+1-i)-0.12, (classNum+1-i) + 0.12], 'Color', [0Power0],' LineWidth',2.5)% draw scatter tY= (rand (length (tX), 1)-0. 5). * 0.24+ones (length (tX), 1). * (classNum+1-i); scatter (tX,tY,15,'CData',colorList), 'MarkerEdgeAlpha',0.15,... 'MarkerFaceColor',colorList (patchCell,dataName:), 'MarkerFaceAlpha',0.1) end% drawing legend lgd=legend (patchCell,dataName); lgd.Location='best';end

Vertical rain cloud picture function rainCloudsTMPL2% @ author: slandarer% put your data here = X1 = [normrnd (8pyrus 4pj1120), normrnd (5pyrus 2pyrs 1pr 25)]; X2 = [normrnd (2.5pyrus 3pyrs 1pyrs 75), normrnd (6miere 4pens 1mons 25s), normrnd (15pals 1p1100)]; X3 = [normrnd (4pens 3pals 1pr 40), normrnd (3pr 4pens 1pens 25)]; X4 = [normrnd (4pr 3pr 140s), normrnd (2jue 4je 1je 75)]; dataCell= {X1rem X2rec X2rex X4} % put the data into the cell array, if there is too much data in a writable loop, put it in the dataName= {'A 'Achievement Magistracy, the name of each data class, but the empty% color list colorList= [0.9294 0.7569 0.5059 0.9176 0.5569 0.4627 0.7020 0.5451 0.4863 0.4314 0.5490] % = classNum=length (dataCell); if size (colorList,1) = = 0 colorList=repmat ([130170172]. / 255, [classNum,1]); else colorList=repmat (colorList, [ceil (classNum/size (colorList,1)), 1]); endif isempty (dataName) for i=1:classNum dataName {I} = ['class',num2str (I)]; endend% coordinate region modifies hold onax=gca;ax.XLim= [1Comp2 classNumeric 2PUB3]; ax.XTick=1:classNum;ax.LineWidth=1.2 Ax.XTickLabels=dataName (end:-1:1); ax.FontSize=14;rate=3.5;% to draw rain cloud map for i=1:classNum tX=dataCell {I}; tX=tX (:); [FMagee Xi] = ksdensity (tX);% Ridge map patchCell (I) = fill (0.2 + [0J F 0]. * rate+ (classNum+1-i). * ones (1), Xi,Xi (end)], ColorList (iPermian:), 'EdgeColor', [0JEI 0],' FaceAlpha',0.8,'LineWidth',1.2);% other data acquisition qt25=quantile (tX,0.25);% lower quartile qt75=quantile (tX,0.75);% upper quartile med=median (tX);% median outliBool=isoutlier (tX,'quartiles');% outlier nX=tX (~ outliBool) Draw box diagrams plot ([(classNum+1-i), (classNum+1-i)], [min (nX), max (nX)], 'kang (nX), max (nX)]; fill ((classNum+1-i) + [- 11-1]. * 0.12, [qt25,qt25,qt75,qt75], colorList (iJournal:),' EdgeColor', [000]) Plot ([(classNum+1-i)-0.12, (classNum+1-i) + 0.12], [med,med], 'Color', [0Power0],' LineWidth',2.5)% draw scatter tY= (rand (length (tX), 1)-0.5). * 0.24+ones (length (tX), 1). * (classNum+1-i); scatter (tY,tX,15,'CData',colorList (iMagnesia:), 'MarkerEdgeAlpha',0.15,... 'MarkerFaceColor',colorList (patchCell,dataName:), 'MarkerFaceAlpha',0.1) end% drawing legend lgd=legend (patchCell,dataName); lgd.Location='best';end

At this point, I believe you have a deeper understanding of "how to draw a rain cloud map with Matlab". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report