2

I am having trouble plotting a patch on a figure with transparency and timestamp index varying in datenum range of 735k, which is more or less the datenum you will acquire for the actual dates.

The following example illustrate my issue:

k=[735172.912437674 735172.941375799 0 7830];
figure;
axis(k);
p=patch([k(1) k(1) k(2) k(2)], [k(3) k(4) k(4) k(3)],[0 0 0 0],'r', 'FaceAlpha', 0.1);

Bug with patch

Are you able to reproduce this bug? Any suggestions? I've seen this other post and searched about it, but no clue. I wouldn't like to remove the minimum from my time stamps, I would have to adapt all the code just because of this x(

Community
  • 1
  • 1
Werner
  • 2,537
  • 1
  • 26
  • 38
  • Interesting... a finite precision issue with openGL? `k=[35172.912437674 35172.941375799 0 7830];` does not cause a problem... – Buck Thorn Aug 24 '13 at 07:56
  • @TryHard I think it is not with openGL because mac does not support it, it is something else. But I managed to find a workaround \o/. – Werner Aug 24 '13 at 16:59
  • This also happens with lines when plotting with `linesmoothing` set to on: `set(0,'DefaultLineLineSmoothing','on')` `set(0,'DefaultPatchLineSmoothing','on')` – Werner Aug 25 '13 at 09:00
  • 1
    I'm convinced it's a finite precision (roundoff) issue somewhere in the pipeline, perhaps before matlab calls the renderer. – Buck Thorn Aug 25 '13 at 11:16
  • I'll keep this thread open, if someone knows another workaround that doesn't uses HG2, it would be very welcome! – Werner Aug 25 '13 at 20:11

1 Answers1

1

I was learning about this other question and they led me to study a bit the new Handle Graphics that may finally appear this or next year (?) — looks like trying to discovering trends at financial business, guess when this will go out, if it will haha. It may be used by adding -hgVersion 2 option at your matlab launch. And by doing so, the resulting figure looks like this \o/:

HG2 somewhere far beyond the limits of HG1 would go

Great… but beware that there are some differences on the usage from the HG1 to the HG2 that may lead your code not to work (specially if you are using listeners) but if you want to explore this even more undocumented code add an if in your codes where it breaks:

if feature('UseHG2')
  % HG2 approach
else
  % HG1 approach
end

One good thing it's that at least we can get the meta.class from the handles, so we can explore them easier x) and the usage is quite more intuitive with the matlab oop development way.

Community
  • 1
  • 1
Werner
  • 2,537
  • 1
  • 26
  • 38
  • Btw, yeah, changing to HG2 just because of this is not that great thing, but one good motivation is that your graphics get prettier, and more customizable… – Werner Aug 24 '13 at 17:36