Why don't my stem graph vertical lines appear?

Hello! I'm currently facing a problem using Matlab r2015a. When I draw a stem graph, the lines that are supposed to connect the points and the horizontal axis, do not appear. How can I make them appear? Thank you for your time.

3 Comments

Can you give us an example of your code?
Well, it's just a normal plot of a graphic. Something like:
x = linspace(-2*pi,2*pi,100);
y = 4*pi*randn(1,100)-2*pi;
figure;
subplot(2,1,1), plot(x,y,'-r.')
subplot(2,1,2), stem(x,y)
Type opengl('save','software') at the MATLAB command prompt. Then, restart MATLAB.

Sign in to comment.

 Accepted Answer

It worked for me. I get vertical lines. Try this, changing the 'LineWidth' property:
x = linspace(-2*pi,2*pi,100);
y = 4*pi*randn(1,100)-2*pi;
figure;
subplot(2,1,1);
plot(x,y,'-r.')
grid on;
subplot(2,1,2);
stem(x,y, 'LineWidth', 3)
grid on;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Stem Test', 'NumberTitle', 'Off')

4 Comments

Well, it shows now. Thank you so much. I just have one question. Will I always have to set the linewidth? In all of my colleagues' PCs, the lines appear without having to do this.
I seem to remember that with R2015a, displaying to an axes that was too small could result in narrow lines effectively vanishing, because the interpolation to a smaller number of pixels might decide they don't contribute enough to show up. That might have been related to anti-aliasing. If so then see if
set(gcf, 'graphicssmoothing', 'off')
makes a difference.
I think they changed the underlying issue for R2015b.
I am not certain on this matter; I could be mis-remembering something I read in the fall.
Unfortunetely it didn't work. Thank you anyway :)
Edit: I made it work. I just changed the anti-aliasing settings on my AMD Catalyst Control Center (GPU drivers).
How changes can be made in anti-aliasing settings on AMD Catalyst Control Center (GPU drivers)

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!