Thank you! That is EXACTLY what the problem is! The issue was with Preview.app on the Mac (I also tried with Powerpoint for Mac and same issue). I'll switch to a native viewer like ghost view from now on.
On Monday, November 5, 2012 4:42:43 AM UTC-8, David Fanning wrote:
> Ailie writes:
>
>
>
>> I'm trying to make a discrete colorbar for an image and plotting straight to postscript. But cgcolorbar.pro is giving some unexpected behaviour.
>
>>
>
>> Basically, I'm trying to plot a discrete colorbar (using the DISCRETE keyword) with 6 colors in postscript. If I plot in using the X device, it behaves as I expect, producing a colorbar with six, distinct divisions, each division filled with a solid block of color.
>
>>
>
>> But when I plot in postscript, my resulting colorbar most definitely has more than 6 colors and instead appears to have graduating color. I'm not sure exactly how many colors, but it's far more than 6. In particular, at the division where my ticks and labels are, the color spans the tick.
>
>>
>
>> Here's my snippet:
>
>>
>
>> cgloadct,0
>
>> cgloadct,2,bottom=1,ncolors=6,/rev
>
>> nc=6
>
>> levels = indgen(7)*5
>
>> lab=string(levels,format='(i3)')
>
>> lab=strcompress(lab,/remove_all)
>
>> cgcolorbar, ticknames=lab, charsize=4, charthick=2,/discrete, $
>
>> bottom=1, ncolors=nc, annotatecolor=cgcolor('black'), font=1, $
>
>> /right, /vert, title = 'levels', pos=[0.87,0.10,0.89,0.90]
>
>>
>
>> As I said, if I plot this in a window using the X device, it's fine and as I expect, but using the postscript device gives far more than 6 levels, with graduating color particularly visible around the tickmarks. You'll note that I load the second colorbar into the first 6 color indices only, but the postscript still results in graduating colors over those 6 colors.
>
>>
>
>> I'm using IDL 8.1 on OS 10.6.5, but have also tried this on IDL 7.0 and IDL 8.2.1 and the same thing happens every time.
>
>
>
> This is not a problem with the PostScript file, nor with
>
> cgColorbar. Rather, it is a problem with the PostScript
>
> viewer on the Mac. It just doesn't want to deal with
>
> less than 256 colors, apparently, so it makes them up
>
> if they aren't there.
>
>
>
> If you made a PNG file out of this PostScript file, you
>
> would see only six colors. And if you use a different
>
> PostScript viewer (say GhostView), you will see only
>
> six colors.
>
>
>
> I don't own a Mac, so I don't know if it is possible to
>
> get the Mac PostScript viewer to see what is actually
>
> there. Does anyone else know?
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|