Is it possible to use GraphicsSmoothing for lines and not for the figure box?

2 vues (au cours des 30 derniers jours)
I see the benefits of having graphics smoothing option, available now since 2014 versions. However, I noticed that the smoothing is applied to all the elements in the figure. Is it possible to switch on the smoothing for the plotted lines, while switching it off when generating the figure's axis lines and box?
I have generated two examples, with and without smoothing.
WITH SMOOTHING ON: <<
>>
SMOOTHING OFF: <<
I would like to have the generated figure as in the WithSmoothing case. But also the axes lines and figure box as in NoSmoothing case, where they appear very sharp and thin. I also would like to set this new configuration as default in my Matlab session.
Note: To switch on/off the smoothing option I use the following command lines: set(groot,'DefaultFigureGraphicsSmoothing','off'); or set(groot,'DefaultFigureGraphicsSmoothing','on');

Réponse acceptée

Mike Garrity
Mike Garrity le 25 Juin 2015
No, it's implemented using MSAA , which means that it applies to all objects which are drawn into the window.
On the other hand, the box and ticks are drawn using AlignVertexCenters. This means that they usually don't get softened by the GraphicsSmoothing.
Consider the following example:
figure('Position',[100 100 300 200])
x = repmat(1:50,[3 1]);
y = repmat([0; 1; nan],[1 50]);
h = line(x(:),y(:),'Color','black')
ylim([-5 5])
title('AlignVertexCenters = off')
Without AVC, the lines are evenly spaced, but a little blurry. That's because some of them are landing "between pixels".
h.AlignVertexCenters = 'on'
title('AlignVertexCenters = on')
With AVC, the spacing between the lines isn't consistent, but the lines look quite crisp.
One possibility is that the LineWidth of your axes is large enough that the edges are touching multiple pixels. The default line with is 1/2 point (1/36th inch). The number of pixels that maps to is a function of your screen resolution. The math looks like this:
get(groot,'ScreenPixelsPerInch')*get(groot,'DefaultAxesLineWidth')/72
If that returns a number which is greater than 1, then you could try turning DefaultAxesLineWidth down a little bit.
I really need to do a post for my blog that explains all of the details.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by