2019-1-25 画图:画风玫瑰图

0.基础知识:

  • RGB是三原色光,红(Red)绿(Green)蓝(Blue)的缩写;
  • 不同的RGB数值组成了不同的颜色,RGB取值范围是0到255之间的整数;
  • 可以组成1670万种颜色;
  • 其中白色的RGB:255,255,255;
  • 黑的RGB:0,0,0;

 

1.matlab画风玫瑰图

两个函数:polar(貌似2015B不支持,可以支持三维、思维的展示)、polarhistogram和rose,参考https://ww2.mathworks.cn/help/matlab/examples/plotting-in-polar-coordinates.htmlhttps://ww2.mathworks.cn/help/matlab/ref/polarhistogram.htmlhttps://ww2.mathworks.cn/help/matlab/ref/rlim.html

% 风玫瑰图示例
x=rand(1000,1)*100;
t=x*pi/180;   % 注意输入的是弧度
rose(t);
view(90,-90); % 图形选装90度
saveas(gcf,'tttR.png')

隐藏坐标轴参考:https://blog.csdn.net/lgh0824/article/details/73610102,但是对于rose画出来的图不太适用。个人找到了一种适合修改任何图的方法:

  • 在Figure图形界面中Edit->Axes Properties,直接点击图中的任意部件删除即可。

图形的去(白色)背景,实现轮廓曲线透明:

参考:https://blog.csdn.net/dcz1994/article/details/72662958 

close all
I=imread('tttR2.png');

G=rgb2gray(I);  %灰度化
ima=imadjust(G);    %调节灰度图像的亮度或彩色图像的颜色矩阵
bw=im2bw(ima);  %二值化默认值是0.5
figure,imshow(bw)

level=graythresh(G);    %使用最大类间方差法找到图片的一个合适的阈值
bw2=im2bw(ima,level);   
figure,imshow(bw2)

bw3=~bw2;   %取反
bw4 =bwareaopen(bw3, 20);
%bw4=imfill(~bw4,'hole');
figure,imshow(bw4)

bw5=~bw4;
R=I(:,:,1);%矩阵的拆分,所有行列的第1个值
G=I(:,:,2);
B=I(:,:,3);

% 字体颜色  %为0的地方(字体部分)赋值为红色
R(~bw5)=0;   
G(~bw5)=255;      
B(~bw5)=0;

%背景颜色 %为1的地方(背景部分)赋值为白色
R(bw5)=255;
G(bw5)=255;
B(bw5)=255;
rgb=cat(3,R,G,B);   %构建矩阵,3为矩阵的维数
figure,imshow(rgb)

%透明度
siz=size(I);
alpha=ones(siz(1),siz(2));
alpha(R==255)=0;    %取背景部分0 0为透明
figure(66),imshow(rgb)
imwrite(rgb,'透明R2.png','Alpha',alpha)

2.Python画风玫瑰图、雷达图(俗称六芒星)、极坐标图:

参考:https://blog.csdn.net/Just_youHG/article/details/83904618

参考:python之windrose风向玫瑰图的用法 https://blog.csdn.net/qq_30638831/article/details/84578280

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
 
# Create wind speed and direction variables
 
ws = np.random.random(500) * 6
wd = np.random.random(500) * 360
 
 
ax = WindroseAxes.from_ax()
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
ax.set_legend()
 
plt.show()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值