Mostrar comentarios más antiguos
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
Respuestas (1)
Daniel Shub
el 28 de Abr. de 2012
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 comentarios
Walter Roberson
el 28 de Abr. de 2012
I believe the FEX contribution "plt" can do hatching.
Walter Roberson
el 28 de Abr. de 2012
What if you set TickLength to 0?
Daniel Shub
el 28 de Abr. de 2012
@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
el 28 de Abr. de 2012
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!