comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Polyfill overlap issue
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Polyfill overlap issue [message #84836] Wed, 12 June 2013 13:39
Jeff Porzio is currently offline  Jeff Porzio
Messages: 1
Registered: June 2013
Junior Member
I am trying to create some fancy error bars that look like Gaussian distributions. To do this, I am plotting polygon using polyfill and then mapping an image onto each polygon with pattern and image_coord. The problem is that the darker portions of the next polygon to be plotted overlaps and overwrites the previous one.

Ideally, I would like a superposition of the two images. That would probably involve normalizing everything after the fact to keep all pixels within 0-255. It would be satisfactory if the brighter pixel was plotted and not the darker ones during the overlap.

I have tried using transparent, but that is not the effect I want to achieve. Any advice?

Code:

PRO fuzzplot

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;% hardcoded sample plot for quick tests %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
size = 10
x = findgen(size)
y = findgen(size)+1
dxRight = fltarr(size)+1
dxLeft = fltarr(size)+1
dyAbove = fltarr(size)+2
dyBelow = fltarr(size)+2


set_plot, 'Z'


;%%%%%%%%%%%%%%%%%%%%%
;% Plot the original %
;%%%%%%%%%%%%%%%%%%%%%
; The plot window will scale according to the actual data, so in order
; for our plots with error to be included totally, we need to manually
; scale the window.
margin = 5
xmin = min(x) - margin*dxLeft[0]
xmax = max(x) + margin*dxRight[n_elements(x)-1]
ymin = min(y) - margin*dyBelow[where(y eq min(y))]
ymax = max(y) + margin*dyAbove[where(y eq max(y))]

;window, 0; Forces axes to scale
plot, x,y, yrange=[ymin,ymax], xrange=[xmin,xmax], xstyle=1, ystyle=1


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;% Does a single pattern work? %
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Need to eventually work out having different sizes.
s = 100
A = 255
b = s/2
c = 23.
Gaussian = fltarr(s,s)
for i = 0,s-1 do begin
for j = 0,s-1 do begin
Gaussian[i,j] = A*exp(-((i-b)^2/(2*c^2)+(j-b)^2/(2*c^2)))
endfor
endfor
;surface, Gaussian


;%%%%%%%%%%%%%%%%%%%%
;% Plot error boxes %
;%%%%%%%%%%%%%%%%%%%%
;% This is good so far, just need to stop them from overlapping and
; having the black of one wipe out the signal of the other.
for i = 0,n_elements(x)-1 do begin
;print, i
; Need to make each polygon individually in order to have closed shapes.
; Starting at bottoom right and moving counter-clockwise...
xCoors = [x[i]-dxLeft[i], x[i]+dxRight[i], x[i]+dxRight[i], x[i]-dxLeft[i]]
yCoors = [y[i]-dyBelow[i], y[i]-dyBelow[i], y[i]+dyAbove[i], y[i]+dyAbove[i]
polyfill, xCoors, yCoors, pattern=Gaussian, $
image_coord=[[0,0],[s,0],[s,s],[0,s]]

endfor

b= TVRD()
set_plot, 'PS'
TV, b
device, /close


end


Many thanks,
Jeff
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Gaussian Function
Next Topic: cgcontour colours for 2 panel plot

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:33:18 PDT 2025

Total time taken to generate the page: 0.00370 seconds