How to add a single line to my plot??

1 回表示 (過去 30 日間)
Brenno Selli
Brenno Selli 2023 年 10 月 20 日
回答済み: Chunru 2023 年 10 月 20 日
I know it seems easy, but I'm having trouble doing this.
I basically need to plot horizontal lines with a length of 0.1m to the left and right of each of the points in my scatterplot.
After that, I need to allocate 2 vertical lines that connect the ends of the two horizontal lines I made previously, this way I would be making a kind of box, the boxplot function doesn't help me in this case, I need to do it this way, no matter how deoptimized or "brute" it is.

採用された回答

Chunru
Chunru 2023 年 10 月 20 日
Your specification is not clear and this is a guess.
x = 2*rand(10, 1);
y = 2*rand(10, 1);
scatter(x, y)
hold on
dx = 0.1; dy = 0.1;
for i=1:length(x)
plot(x(i)+dx*[-1 1 1 -1 -1], y(i)+dy*[-1 -1 1 1 -1], 'r-');
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExploration and Visualization についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by