MATLAB Answers

The thickness of border lines on a plot (different than that of the inner lines)

26 views (last 30 days)
inci
inci on 9 Aug 2012
Dear All,
I was wondering why the thickness of the border lines on my simple grid plot are different on the left and top corners (than right and bottom) and they are all thinner than the inner lines with the following code in which I set the thickness the same for all (set(Z, 'LineWidth', 3)). I would so much appreciate your comments:
PS: Please note that the crowded "Z=..." bit on the code is just to define the lines and the fixation spot.
set(gcf,'doublebuffer','on');
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
set(gcf,'Color',[1 1 1]);
k=1;
rannum1(1)=0;
rannum2(1)=0;
x_min=0; x_max=600; y_min=0; y_max=600;
%r=topleft corner point, s=topright corner, m=bottomleft corner,
%n=bottomright corner
r=[0 600]; s=[600 600]; m= [0 0]; n= [600 0];
Z=plot([r(1) s(1)], [r(2), s(2)] , '-black', [r(1) m(1)], [r(2), m(2)] , '-black', [m(1) n(1)], [m(2), n(2)] , '-black', [s(1) n(1)], [s(2), n(2)] , '-black', [(r(1)+s(1))/2 (((r(1)+s(1)+m(1)+n(1))/4)+rannum1(k))], [(r(2)+s(2))/2 (((r(2)+s(2)+m(2)+n(2))/4)+rannum2(k))], '-black', [(((r(1)+s(1)+m(1)+n(1))/4)+rannum1(k)) (m(1)+n(1))/2], [(((r(2)+s(2)+m(2)+n(2))/4)+rannum2(k)) (m(2)+n(2))/2], '-black', [(r(1)+m(1))/2 (((r(1)+s(1)+m(1)+n(1))/4)+rannum1(k))], [(r(2)+m(2))/2 (((r(2)+s(2)+m(2)+n(2))/4)+rannum2(k))] , '-black', [(((r(1)+s(1)+m(1)+n(1))/4)+rannum1(k)) (s(1)+n(1))/2], [(((r(2)+s(2)+m(2)+n(2))/4)+rannum2(k)) (s(2)+n(2))/2], '-black', 300, 300, 'o', 'MarkerEdgeColor','none','MarkerFaceColor','r', 'MarkerSize',12);
set(Z, 'LineWidth', 3);
axis([x_min x_max y_min y_max]);
axis square
axis off
set(gca, 'visible', 'off', 'units', 'normalized', 'position', [0.200 0.230 0.60 0.60]);
Thank you very much!
inci

Answers (1)

Sebastian Holmqvist
Sebastian Holmqvist on 9 Aug 2012
Edited: Sebastian Holmqvist on 9 Aug 2012
I found that the figure automatically chooses the renderer ZBuffer, which is the cause of your display issues. I can't answer as to why it's not rendering properly, but manually setting the renderer to either 'Painter' or 'OpenGL' does the trick!
set(gcf, 'renderer', 'opengl')
or
set(gcf, 'renderer', 'painter')
  2 Comments
Sebastian Holmqvist
Sebastian Holmqvist on 9 Aug 2012
This is because of the different way each renderer draws the picture.
"OpenGL and Zbuffer renderers display objects sorted in front to back order, as seen on the monitor, and lines always draw in front of faces when at the same location on the plane of the monitor. Painters sorts by child order (order specified)."
So try plotting the center in a separate plot, or earlier in your current plot-spec.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!