フィルターのクリア

How to mark one specific point when plotting

4 ビュー (過去 30 日間)
Anton Larsson
Anton Larsson 2011 年 10 月 14 日
Hi,
Consider the following plot:
x = linspace(0,10)
y = x.^2
plot(x,y,'b+-')
What type of command can I use to mark one specific point on the line, e.g. y(2), with a square size 15?
Cheers,
A MATLAB newbie

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 14 日
Guessing that you want 15 x 15 centered over (x(2),y(2)), then:
rectangle('Position',[x(2)-15/2 y(2)-15/2 15 15])
Note: the answer is in terms of 15 data units. If you want 15 pixels, then:
PointsPerPixels = 72/get(0,'ScreenPixelsPerInch');
line(x(2),y(2),'Marker','s','MarkerSize', 15 * PointsPerPixel)

その他の回答 (1 件)

Ali Isik
Ali Isik 2011 年 10 月 14 日
As I understood you should 'hold on' the plot and plot the colored,squared point on it. The modified code is as follows;
x = linspace(0,10);
y = x.^2;
plot(x,y,'b+-');
hold on;
plot(x(2),y(2),'--rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',15);
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 10 月 14 日
Note: that 15 will be 15 points.
Reminds me about the riddle of St. Ives...

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

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by