matlabbar填充花纹,Matlab中画花纹填充的柱状图

更新时间:2023-06-05 06:01:55 阅读: 评论:0

matlabbar填充花纹,Matlab中画花纹填充的柱状图在画柱状图时,利⽤不同的颜⾊区分在实际打印时经常区分不出。
为了能够更清楚第表⽰最终结果,可采⽤在柱状图中打阴影的⽅式来表⽰。
然⽽,Matalab本⾝没有提供实现这种功能的函数库。
下⾯两个函数:
% ApplyBrandon
's function
applyhatch_pluscolor母亲节快乐的英文
% Apply Brian'sfunction
applyhatch_plusC(fH,'\-x.', 'rkbk');
实现了上述功能。
这两个函数中都调⽤了函数makehatch_plus源码如下(都已经调试通过,可⽅便使⽤)。
h = bar(rand(3,4));
%随机⽣成3⾏4列的矩阵
fH = gcf;
colormap(jet(4));
%参数4表⽰4列数的颜⾊
legend('Apple', 'Orange', 'Banana','Melon', 'Location',
'EastOutside');
% Apply
Brandon'sfunction(PS:接着上⾯的代码写)
tH = title('Brandon''s applyhatch');
applyhatch_pluscolor(fH,'\-x.', 0, [1 0 1 0], jet(4));
%参数4可改变
% Apply Brian'sfunction
t(tH, 'String','Brian''s applyhatch');
applyhatch_plusC(fH,'\-x.', 'rkbk');
t(tH, 'String','Original');
代码源⾃:提供的读音
function[im_hatch,colorlist] =
ihtcapplyhatch_pluscolor(h,patterns,CvBW,Hinvert,colorlist,...
dpi,hatchsc,lw)
BW or Color
%  APPLYHATCH_PLUSCOLOR(H,PATTERNS) creates anew figure from the figure H by
%  replacing distinct colors in H with
the blackand white
%  patterns in PATTERNS. The format for PATTERNScan be
%    a
string of the characters:
%
'/', '\', '|', '-', '+', 'x', '.', 'c','w', 'k'
%
(e makehatch_plus.m for more details) or
%    a
cell array of matrices of zeros (white) andones (black) %
%  In addition, H can alternatively be a
uint8NxMx3 matrix of the type
%  produced by imread.
In this ca, colors in this image will be
%  replaced with patterns as if it was
afigure.  A final figure window
%  will be generated that displays
theresult.  The DPI argument
%  discusd below will be ignored if H
is animage matrix.
%
%  APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW) binaryvalue for choice of Color or Black
%  and White plots. If color is chon
the colorwill match that of the
%  current fill. 1 ->
rerve是什么意思Color, anything el-> BW
region是什么意思
%
APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW,HINVERT)binary value to invert the hatch.
%  i.e., if it is black lines with a
whitebackground, that becomes white
%  lines with a black background. This
can eitherbe a scalar value or a
%  1xN array equal to the length of
PATTERNS.When ud as an array each
%  PATTERNS(i) will be inverted according
toHinvert(i). 1 -> Invert,
%  anything el -> Non
Inverted
%
% APPLYHATCH_PLUSCOLOR(H,PATTERNS,CVBW,HINVERT,COLORS)
maps the colors inthe n by 3
%  matrix COLORS to PATTERNS. Each row of
COLORSspecifies an RGB
%  color value.
%
%  Note this function makes a bitmap
image of Hand so is limited
%  to bitmap output.理智与情感电影下载
%
%  Additional arguments:
%
%  [im_hatch,colorlist]
熟能生巧英语
=applyhatch_plus(h,patterns,CvBW,Hinvert,colorlist,dpi,hatchsc,linewidth)
%
%
input  DPIwinter ro
allows specificationof bitmap resolution, making plot
resolution
better forprinting.  Ignored if H is an imagematrix.
%
HATCHSC    multiplier
for hatch scale to increa size of pattern for betteroperation
%
at higher resolutions
%
default [] us screenresolution as in
%
APPLYHATCH
%
LINEWIDTH  A scaling factor to
apply to line and dotsizes
%
in hatching.  Defaults to 1.
%
output IM_HATCH
RGB bitmap matrix ofnew figure
%
u IMWRITE to output indesired format
%
COLORLIST  List of colors
actually replaced.  Uful info if
%
no colorlist initiallygiven to function.
%
Colorlist will be uint8,not 0-1 scale as
%
originally specified.
%
%  Example 1:
bar(rand(3,4));
%
[im_hatch,colorlist]
=applyhatch_pluscolor(gcf,'\-x.',0,0,[],150);
%
imwrite(im_hatch,'im_hatch.png','png')
%
%  Example 2:
%
bar(rand(3,4));
%
[im_hatch,colorlist]
=applyhatch_pluscolor(gcf,'\-x.',1,[],[],150);
%
imwrite(im_hatch,'im_hatch.png','png')
%
%  Example 3:
%
colormap(cool(6));
%
pie(rand(6,1));
%  legend('Jan','Feb','Mar','Apr','May','Jun');
%
im_hatch =applyhatch_pluscolor(gcf,'|-.+\/',1,[1 1 0 1 0 0],cool(6),200,3,2);
%
英文圣诞歌imwrite(im_hatch,'im_hatch.png','png')
%
%  Example 4: Produces roughly the same
thing axample 1keepcalm
%
bar(rand(3,4));
%

本文发布于:2023-06-05 06:01:55,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/868846.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:柱状图   函数   花纹   实现   功能   提供
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图