Compass plot issue with refreshdata command

5 ビュー (過去 30 日間)
Simon
Simon 2011 年 4 月 6 日
I'm having trouble dynamically updating a Compass plot by modifying the variables and then using the refreshdata command to update the plot.
For instance, this simple example below, which is a basic abstraction of what I'm doing, doesn't work as expected:
x = [10 20 15 19]
y = [21 18 14 10]
h = compass(x,y)
set(h,'YDataSource','y')
set(h,'XDataSource','x')
x = [400 300 430 302]
refreshdata
This just results in a blank graph/plot. Is there something obvious I'm missing here?
Thanks for your help!

回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 4 月 6 日
compass() creates one arrow per (x,y) pair, with each arrow being a lineseries object that draws from the origin to the point then to the end of the first barb, back to the point, then to the end of the second barb -- a total of five points per handle. When you set the XDataSource for the collection of handles returned by compass(), if it worked you would be commanding that all of the handles be changed to have their x values exactly the same but with the y values unchanged. That's not likely to be what you want.
The lack of visual update is probably because there would be a mismatch between length 4 of the new x values and the existing 5 y values per handle (5 to draw barbs): if you had happened to use 5 x values in the vector, you'd get some rather odd-looking barbs.
refreshdata() is not useful for commands that draw compound objects on your behalf, only for simple line plots of vectors (not even plot() of a matrix.)
  1 件のコメント
Simon
Simon 2011 年 4 月 10 日
thanks! Much appreciated.

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

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by