필터 지우기
필터 지우기

Area Plots

조회 수: 3 (최근 30일)
old_user_rat
old_user_rat 2012년 4월 28일
Dear all,
I am using the code below to colour different areas of a plot. I have 2 questions: 1)I would however like to use shading that is not just solid colour. For example I would like to have a striped area.
2) I would like to remove the x and y axis ticks, but NOT the tick labels.
Does anyone know how I can do these things?
clear
p=0:0.001:0.25;
a1=p.^2;
p=0.251:0.001:0.5;
a2=(p-1/2).^2;
a=[a1 a2];
p=0:0.001:0.207;
b1=2*p.^2;
p=0.208:0.001:0.5;
b2=(p-1/2).^2;
b=[b1 b2];
c=b-a;
p=0:0.001:0.207;
d1=(p + (1 - 4*p).^(1/2)/2).^2/2;
p=0.208:0.001:0.5;
d2=(p-1/2).^2;
d=[d1 d2];
e=d-b;
f1=0.25-d1;
f2=0.25-b2;
f2(43:293)=0;
f=[f1 f2];
p=0:0.001:0.5;
Y=[a' c' e' f'];
h=area(p,Y);
set(h(1),'FaceColor',[0.098039 0.74118 0.81961]);
set(h(2),'FaceColor',[0.87059 0.56863 0.97647]);
set(h(3),'FaceColor',[0.97647 0.55686 0.84314]);
set(h(4),'FaceColor',[0.98431 0.41176 0.41176]);
set(gca,'xticklabel',[0 0.207 0.25 0.5],'yticklabel',[0 0.0625 0.086 0.125 0.25],'xtick',[0 0.207 0.25 0.5],'ytick',[0 0.0625 0.086 0.125 0.25])
xlabel('p')
ylabel('c')
Thanks,
David

답변 (1개)

Daniel Shub
Daniel Shub 2012년 4월 28일
I think the answer to both your questions is you cannot do it easily in MATLAB.
For the tick labels it is not so bad. You can use FEX: rotateXLabels, with no rotation to take care of the ugliness. Then you should be able to do
set(gca, 'XTick' []);
If you make any changes to your plot after then, the tick labels will be all screwed up.
If you really want to plot striped areas I would look at FEX: hatch. It is setup for bar graphs, but you might be able to learn something for the code and transfer it to area plots.
  댓글 수: 4
Daniel Shub
Daniel Shub 2012년 4월 28일
@Walter, wow and wow. You should make these comments an answer, as it is much better than mine. Do you know if the FEX plt is at all similar to http://physionet.org/physiotools/plt/
old_user_rat
old_user_rat 2012년 4월 28일
@Walter, thanks very much, set(gca,'TickLength',[0 0]) did the job nicely. @both, Will have a bash at the hatching, but looks a bit daunting to integrate it with the area plot.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by