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

Home » Public Forums » archive » Pain with the contour() function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Pain with the contour() function [message #94498 is a reply to message #94497] Wed, 14 June 2017 08:45 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 06/14/2017 05:09 PM, Helder wrote:
> I was trying to plot an image with the contour function and I banged my head against the monitor for a while. I now have the solution and I'm sharing it. Probably most people know this very well. I didn't.
> I followed the example given for the colorbar() function (Example: Discrete Contour Levels with Colorbar):
> http://www.harrisgeospatial.com/docs/Colorbars.html
>
> So I generated my data with the code below and it appeared strangely shifted to the side.
>
> dis = dist(688)
> n_levels = 6
> levels = findgen(n_levels)
> ct_number = 4
> ct_indices = bytscl(levels)
> loadct, ct_number, rgb_table=ct, /silent
> step_ct = congrid(ct[ct_indices, *], 256, 3)
> dis = (n_levels-1)*dis/max(dis)
> ii = contour(dis, c_value = levels, rgb_table = step_ct, rgb_indices = ct_indices, /fill, axis_style=0)
>
> I then started playing around with the position and margin keywords, but had no luck. Finally it all comes down to using xRange and yRange (or xStyle=1, yStyle=1):
>
> ii = contour(dis, c_value = levels, rgb_table = step_ct, rgb_indices = ct_indices, /fill, axis_style=0, xStyle=1, yStyle=1)
>
> The reason is that contour() plots images as if they were plots, so it defines some axis around it and you have to make sure you're not having uncovered regions.
>
> Well, back to work.

another pain with contour, or any combination of raster graphics and
vector graphics elements is, that they are natively offset by half a
pixel (or whatever you want to call the data unit here):

c=contour(dist(10),overplot=image(35*dist(10),dimension=[250 ,250], $
position=[25,25,225,225],/dev))

the solution to that is

contour, dist(10), path_xy=line, path_info=info, /path_data_coord, $
closed=0,levels=[0:6]
i1=image(35*dist(10),dimension=[250,250], $
position=[25,25,225,225],/dev)
foreach in,info do p=plot(line[*,in.offset+[lindgen(in.n),in.type ? 0 :$
!null]]+.5, color=255b-[40b,40b,0b]*byte(in.value),overplot=i1)

-- Markus
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: curved slit
Next Topic: *** Error: checking data fill: tried to move past end of file

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

Current Time: Wed Oct 08 13:49:48 PDT 2025

Total time taken to generate the page: 0.00447 seconds