Problem with markers & dashed lines in figures containing both plot and fill
4 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Matt Fig
on 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!