Plot on top of semilogy plot

4 views (last 30 days)
Brian
Brian on 18 Jul 2014
Answered: Star Strider on 18 Jul 2014
Hello, thanks for reading this,
I want to make a plot on top of a semilogy plot. What I mean by this is the following:
I have a test row array:
B = [236715 13924 3292 2158 1450 971 977 1180 1117 360]
and I create a semilogy plot with the command:
semilogy(B, '*-')
Now, just for some look-pretty visualization, I want to add something on top of this: lines coming from each of the points down to the x axis. Using the major gridlines isn't what I mean, I mean plotting on top of this lines from each of the 10 points back down to the x axis (coloring will change depending on parameters).
I use the code listed here:
for i=1:10
hold on
line([i i],[B(i) 0], 'r')
end
to make the lines, but it doesn't show up. I can make hold on plots just using individual points, but any kind of traced line I try to create doesn't work. I tried using this code with the plot of B, instead of the semilogy plot, and it works, but the data doesn't look as good. Is there a way to trace on top of this?
Thanks!

Accepted Answer

Star Strider
Star Strider on 18 Jul 2014
Try the stem plot function:
B = [236715 13924 3292 2158 1450 971 977 1180 1117 360];
L = length(B);
figure(1)
semilogy(B, '*-')
hold on
stem(1:L, B, 'r')
hold off

More Answers (0)

Categories

Find more on Line 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!