Patch/fill resolution problem

1 回表示 (過去 30 日間)
Jakob Sievers
Jakob Sievers 2011 年 10 月 22 日
Hi there
I am plotting around 10mio points within an axis range of [0 8 0 400]. I am then using patch/fill to plot several slightly transparent rectangles spanning the entire vertical domain, in order to illustrate different properties of these points (say for instance: all points between 0 and 1 on the x-axis are marked with a red transparent rectangle). My problem is that some of these rectangles span a fairly narrow space on the x-axis, and the result is that patch/fill reduce what ought to be a rectangle to a vertical line (i.e.: the edge of the proposed rectangle). The narrowest of these rectangles is 0.02 wide, which I feel should still be possible to depict. Even if this is not possible I would still like to be able to see these rectangles when exporting the picture as a high-resolution jpg using "print", but that is not the case.
Has any of you ever bumped into this issue and does anyone have a clever solution?
Thanks in advance
-Jakob

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 22 日
Supposing your figure was 1024 x 768 pixels, your maximum actual drawing area would be less than 1000 pixels wide, but let's call it 1000 pixels for a moment. You are packing a data range of 400 (or maybe 401, but the numbers work out nicer for 400) in to that 1000 pixels, so an x change of 1 would correspond to 2 1/2 pixels wide.
Now, if I have understood your units correctly (and I am not sure that I have), you want to plot a rectangle that is 0.02 data units wide. Multiply that by the 2 1/2 pixels per data unit, and your proposed rectangle would be 0.05 pixels wide. patch() is either going to ignore that as being too small to draw, or is going to draw it as a single pixel.
What pixel width would you need in order for such a rectagle to be two pixels wide instead of a single line? Your width would have to be at least such that W * (0.02 / 400) rounds upward to 2, so W * (0.02/400) = 1.5 at least. That requires an axes pixel width W of at least 30000, preferably higher.
Now, ordinarily you might be able to accomplish such a thing by using a vector graphics export and magnifying as needed, but the only renderer that supports vector graphics does not support transparency. The only renderer that supports transparency is OpenGL, which only supports bitmap rendering.
It has never been clear to me exactly how printing works internally and how high internal resolution can be generated for saved images. What I can suggest, though, is that your approach most likely to lead to success is to use Oliver's file Exchange contribution "export_fig".
  1 件のコメント
Jakob Sievers
Jakob Sievers 2011 年 10 月 24 日
I played around a bit with the export_fig function. This seems like a very handy piece of code, which I'm definitely going to use for other purposes in the future. After struggling with patch and fill for a few days, I chose to simply use vertical lines, centered around the x-axis index that I wanted to mark. Since what I'm working on is primarily intended for personal data-analysis, there's no need to waste too much time "shooting Sparrows with canons" so to speak.
Thanks for the help though! It was much appreciated!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by