plot vector where negative data is circled

2 次查看(过去 30 天)
If I e.g. have the following two vectors:
data = [1 2 3 -4 -5 6 -7 8 9 -10]
pos = [1 2 3 4 5 6 7 8 9 10]
How can I do
plot(abs(data),pos)
set(gca,'xscale','log');
where only the negative data is circled? Is that even possible without stepping through each data point?

采纳的回答

Rick Rosson
Rick Rosson 2015-3-13
编辑:Rick Rosson 2015-3-13
isNeg = (data < 0);
plot(abs(data),pos)
hold on
plot(abs(data(isNeg)),pos(isNeg),'o')
set(gca,'xscale','log');

更多回答(1 个)

Toke Søltoft
Toke Søltoft 2015-3-13
thanks so much. Works like a charm.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by