Mercurial > octave
comparison scripts/plot/draw/private/__scatter__.m @ 21330:fb7f40558553
Fix callback routine for updating scatter plots (bug #47237).
* __scatter__.m (update_data): Add all construction cases from function scatter
to callback routine update_data for case where number of points is <= 100. Emit
an error if the number of points is greater than 100 and suggest the alternative
of re-invoking scatter with the new data.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Feb 2016 08:34:59 -0800 |
parents | 516bb87ea72e |
children | 683a1beee538 |
comparison
equal
deleted
inserted
replaced
21329:1d8e020d86df | 21330:fb7f40558553 |
---|---|
353 | 353 |
354 set (kids, "linewidth", lw, "marker", m, | 354 set (kids, "linewidth", lw, "marker", m, |
355 "markerfacecolor", fc, "markeredgecolor", ec); | 355 "markerfacecolor", fc, "markeredgecolor", ec); |
356 endfunction | 356 endfunction |
357 | 357 |
358 ## FIXME: This callback routine doesn't handle the case where N > 100. | |
358 function update_data (h, d) | 359 function update_data (h, d) |
359 x = get (h, "xdata"); | 360 x = get (h, "xdata"); |
360 y = get (h, "ydata"); | 361 y = get (h, "ydata"); |
361 z = get (h, "zdata"); | 362 z = get (h, "zdata"); |
363 if (numel (x) > 100) | |
364 error ("scatter: cannot update data with more than 100 points. Call scatter (x, y, ...) with new data instead."); | |
365 endif | |
362 c = get (h, "cdata"); | 366 c = get (h, "cdata"); |
363 if (rows (c) == 1) | 367 one_explicit_color = ischar (c) || isequal (size (c), [1, 3]); |
364 c = repmat (c, numel (x), 1); | 368 if (! one_explicit_color) |
365 endif | 369 if (rows (c) == 1) |
370 c = repmat (c, numel (x), 1); | |
371 endif | |
372 endif | |
373 filled = ! strcmp (get (h, "markerfacecolor"), "none"); | |
366 s = get (h, "sizedata"); | 374 s = get (h, "sizedata"); |
367 if (numel (s) == 1) | 375 if (numel (s) == 1) |
368 s = repmat (s, numel (x), 1); | 376 s = repmat (s, numel (x), 1); |
369 endif | 377 endif |
370 hlist = get (h, "children"); | 378 hlist = get (h, "children"); |
371 | 379 |
372 if (isempty (z)) | 380 if (one_explicit_color) |
373 for i = 1 : length (hlist) | 381 if (filled) |
374 set (hlist(i), "vertices", [x(i), y(i)], | 382 if (isempty (z)) |
375 "cdata", reshape (c(i,:),[1, size(c)(2:end)]), | 383 for i = 1 : length (hlist) |
376 "facevertexcdata", c(i,:), | 384 set (hlist(i), "vertices", [x(i), y(i)], |
377 "markersize", s(i)); | 385 "markersize", s(i), |
378 endfor | 386 "markeredgecolor", c, "markerfacecolor", c); |
379 else | 387 |
380 for i = 1 : length (hlist) | 388 endfor |
381 set (hlist(i), "vertices", [x(i), y(i), z(i)], | 389 else |
382 "cdata", reshape (cd(i,:),[1, size(cd)(2:end)]), | 390 for i = 1 : length (hlist) |
383 "facevertexcdata", cd(i,:), | 391 set (hlist(i), "vertices", [x(i), y(i), z(i)], |
384 "markersize", s(i)); | 392 "markersize", s(i), |
385 endfor | 393 "markeredgecolor", c, "markerfacecolor", c); |
394 endfor | |
395 endif | |
396 else | |
397 if (isempty (z)) | |
398 for i = 1 : length (hlist) | |
399 set (hlist(i), "vertices", [x(i), y(i)], | |
400 "markersize", s(i), | |
401 "markeredgecolor", c, "markerfacecolor", "none"); | |
402 | |
403 endfor | |
404 else | |
405 for i = 1 : length (hlist) | |
406 set (hlist(i), "vertices", [x(i), y(i), z(i)], | |
407 "markersize", s(i), | |
408 "markeredgecolor", c, "markerfacecolor", "none"); | |
409 endfor | |
410 endif | |
411 endif | |
412 else | |
413 if (filled) | |
414 if (isempty (z)) | |
415 for i = 1 : length (hlist) | |
416 set (hlist(i), "vertices", [x(i), y(i)], | |
417 "markersize", s(i), | |
418 "markeredgecolor", "none", "markerfacecolor", "flat", | |
419 "cdata", reshape (c(i,:),[1, size(c)(2:end)]), | |
420 "facevertexcdata", c(i,:)); | |
421 endfor | |
422 else | |
423 for i = 1 : length (hlist) | |
424 set (hlist(i), "vertices", [x(i), y(i), z(i)], | |
425 "markersize", s(i), | |
426 "markeredgecolor", "none", "markerfacecolor", "flat", | |
427 "cdata", reshape (c(i,:),[1, size(c)(2:end)]), | |
428 "facevertexcdata", c(i,:)); | |
429 endfor | |
430 endif | |
431 else | |
432 if (isempty (z)) | |
433 for i = 1 : length (hlist) | |
434 set (hlist(i), "vertices", [x(i), y(i)], | |
435 "markersize", s(i), | |
436 "markeredgecolor", "flat", "markerfacecolor", "none", | |
437 "cdata", reshape (c(i,:),[1, size(c)(2:end)]), | |
438 "facevertexcdata", c(i,:)); | |
439 endfor | |
440 else | |
441 for i = 1 : length (hlist) | |
442 set (hlist(i), "vertices", [x(i), y(i), z(i)], | |
443 "markersize", s(i), | |
444 "markeredgecolor", "flat", "markerfacecolor", "none", | |
445 "cdata", reshape (c(i,:),[1, size(c)(2:end)]), | |
446 "facevertexcdata", c(i,:)); | |
447 endfor | |
448 endif | |
449 endif | |
386 endif | 450 endif |
387 | 451 |
388 endfunction | 452 endfunction |
389 | 453 |