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

4 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Matt Fig
Matt Fig am 23 Aug. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by