Compass plot issue with refreshdata command
5 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Walter Roberson
on 6 Apr 2011
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.)
See Also
Categories
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!