plottype matlab,关于matlab:Plot-Tiny-Tricks-for-MATLAB-绘图的小技巧

MATLAB plot Tiny Tricks — by Optic_css

Use set(gca, ·, ·, ·, ···) HANDLE for editing

[纪录] 这里是我常常应用的MATLAB制图Code,记录下来是为了当前更快地实现一些根本的制图Setting类的操作,换句话说,当作查阅的备用叭… …

上面所展现的Codes是一些根本的绘图Setting,很容易能看懂,根本蕴含了对于一张图像

‘colormap’

‘grid’

‘box’

‘xtick’、’ytick’、’LinwWidth’、’FontName’、’Color’

‘xlabel’、’ylabel’、’title’、’legend’

‘axis’

的设置,这样曾经算是根本满足了需要… …

% Close all image windows

close all;

%———————————————————————————————————————————————————

%|···········Plotting/Facing Codes Here············|

%———————————————————————————————————————————————————

% Retain control of the current diagram window

hold on;

% 逆転/バック・キック colormap

colormap(flipud(othercolor('Spectral9')));

% colormap(othercolor('Spectral9'));

% Add a plaid shading

grid on;

% Remove the outer frame of the drawing window

box off;

%———————————————————————————————————————————————————

%|·········Use set(·) to Change the style··········|

%———————————————————————————————————————————————————

% set(gca,'xticklabel',roundn((50:50:500)*deltal,-1));

set(gca,'xtick',20:20:180);

% set(gca,'yticklabel',roundn((50:50:500)*deltal,-1));

% set(gca,'yTickLabel',num2str(get(gca,'yTick')','%.12f'));

set(gca,'ytick',50:50:500);

set(gca,'Linewidth',1.5);

set(gca,'FontName','Times New Roman');

set(gca,'Color',[1.000000000000000 0.388235294117647 0.278431372549020]);

%———————————————————————————————————————————————————

%|·················set the labels··················|

%———————————————————————————————————————————————————

xlabel('\xi');

ylabel('\xi');

title('\xi');

legend('相邻方向差分值','FontName','微软雅黑');

%———————————————————————————————————————————————————

%|······Axis setting, use the handle axis(·)·······|

%———————————————————————————————————————————————————

axis([0 5400 30 80]);

legend(['$\bar{x}(\lambda)$';'$\bar{y}(\lambda)$';'$\bar{z}(\lambda)$'],'interpreter','latex');

上面则是一个小trick,对于如何将图窗background变通明的Setting办法,次要是前面对于’InvertHardCopy’的setting,这是属于某个凶恶分享者的资源,

%———————————————————————————————————————————————————

%|·····················Trans·······················|

%———————————————————————————————————————————————————

% If you ever wondered this: which is particularly useful when you export it to formats that feature transparency, like eps, gif, png, ...

% you created a figure and guess the configuration as below:

set(gcf,'color','none');

set(gca,'color','none');

% but this following little detail took me ages to figure out

set(gcf,'InvertHardCopy','off');

A useful (MAYBE) HEX-RGB to String convertor

上面是一个将hexadecimal RGB色调代号转换为MATLAB实用的色调值,也即

输出一个$\rm string:\ ”ff 63 47”/”ff-63-47”$

输入一组向量

$\rm col=1\times3$

$1.000000000000000\ \ \ 0.388235294117647\ \ \ 0.278431372549020$

设计中采纳inline function $\rm hexstr(·)$,做成了一个vector函数的格局,当需要很大的时候,可能显著减小calling所带来的耗费,

col = hex2nstr(["ff 63 47","2e 8b 57","6a 5a cd"]);

%————————————————————————————————————————————————————————————

%|··by Optic_css, the nStr(·) can help you get the [1,1,1]··|

%————————————————————————————————————————————————————————————

function nStr = hex2nstr(hexstr)

% Function that helos to get the normalized str used in MATLAB color spaces

nStr = [];

for io = 1:length(hexstr)

% Splitor to get the divided types, "ff 0a 89"/"ff-0a-89" -> "ff","oa","89"

splitor = strsplit(hexstr(io), '["-", ]',"DelimiterType","RegularExpression");

% Divide the splitor into 3 pieces

dec_ = cell2mat(splitor(1,1));

dec__ = cell2mat(splitor(1,2));

dec___ = cell2mat(splitor(1,3));

% Divided by 255: "ff", and take string addtion

nStr = [nStr;[hex2dec(dec_)/255 hex2dec(dec__)/255 hex2dec(dec___)/255]];

end

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值