plotting an open circle (open interval) in plot

i am plotting a function f =@(x) x.^2 but i want to put open circles at x = 0 and x = 4 because they are undefined at those points. How do i put the open circles?
I am using fplot(f, [0,2])

5 件のコメント

KSSV
KSSV 2020 年 5 月 27 日
What do you mean by open circles?
cgo
cgo 2020 年 5 月 27 日
I meant, when you manually plot (using pen and paper) an open interval (0,4), you put an open (unshaded) circle at the endpoints 0 and 4. How do you replicate the open/unshaded circles in matlab?
darova
darova 2020 年 5 月 27 日
Can you make a simple sketch? How do you want it to look?
cgo
cgo 2020 年 5 月 27 日
See the small circle there? I want it to be larger. (or is there an easier way to do this) because I am graphing an open interval, so it is 'not defined' at y = 4, hence the open/unshaded circle.
darova
darova 2020 年 5 月 27 日
Use markerSize property
plot(x(end),y(end),'ob','markersize',20)

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2020 年 5 月 27 日

1 投票

Try this:
% Create data.
x = linspace(0, 4, 1000);
y = x .^ 2;
% Plot the quadratic curve.
plot(x, y, 'b-', 'LineWidth', 2); % Plot line.
hold on; % Don't let circles blow away the line.
plot([x(1), x(end)], [y(1), y(end)], 'ro', 'MarkerSize', 15, 'LineWidth', 2);
grid on;
xlabel('X', 'FontSize', 15);
ylabel('Y', 'FontSize', 15);
Adjust MarkerSize and LineWidth as desired.

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

cgo
2020 年 5 月 27 日

回答済み:

2020 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by