Borrar filtros
Borrar filtros

Patch/fill resolution problem

5 visualizaciones (últimos 30 días)
Jakob Sievers
Jakob Sievers el 22 de Oct. de 2011
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Oct. de 2011
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 comentario
Jakob Sievers
Jakob Sievers el 24 de Oct. de 2011
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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by