Problem with markers & dashed lines in figures containing both plot and fill

8 vues (au cours des 30 derniers jours)
Sohail
Sohail le 23 Août 2012
The legend gets somewhat distorted in plots that contain both lines and fill objects. For example, compare the legend produced by this:
figure;
plot(linspace(0,pi,25),cos(linspace(0,pi,25)),'s--','LineWidth',2,'MarkerFaceColor','b');
hold on;
plot([0 pi],[0.5 0.5],'-or','LineWidth',2,'MarkerFaceColor','r');
h = fill([0 pi pi 0],[1 1 -1 -1],'g','FaceAlpha',0.15);
hA = get(h,'Annotation');
hA.LegendInformation.IconDisplayStyle = 'off';
legend({'Cosine','Constant'},'interpreter','latex');
with the output when we don't have the fill object:
figure;
plot(linspace(0,pi,25),cos(linspace(0,pi,25)),'s--','LineWidth',2,'MarkerFaceColor','b');
hold on;
plot([0 pi],[0.5 0.5],'-or','LineWidth',2,'MarkerFaceColor','r');
legend({'Cosine','Constant'},'interpreter','latex');
Any solution would be appreciated.
EDIT: At first, I didn't realize that the markers on the plot lines also get distorted as well. So I guess, this whole problem is caused by fill.

Réponse acceptée

Matt Fig
Matt Fig le 23 Août 2012
This is a problem with the opengl renderer. When you have a transparency, you are using opengl, and it can be buggy. To see the difference, click on that figure then:
set(gcf,'render','painters')
Notice the legend looks fine but your transparency has gone away. I am not sure if there is a fix for this.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by