From: sfeam (E. Merritt) <eam...@gm...> - 2010-09-30 04:02:46
|
On Sunday 26 September 2010, Manfred Schwarb wrote: > >> As Dan suggested, if there are only 5 colors in the palette then we need > >> only draw 5 rectangles in the color box. Unlike the current code, > >> however, they shouldn't be evenly spaced. The endpoints of each rectangle > >> should be taken from the palette definition so that they will indeed be > >> placed with perfact accuracy. I have modified the routine that draws the colorbox for non-PostScript terminals. It now checks each little colored rectangle that makes up the colorbox to see if it straddles a break-point in a defined color palette. If so, that little rectangle is split into two smaller rectangles so that their boundary lies exactly at the point where the palette is potentially discontinuous. This gives pixel-accuracy for defined palettes so long as the terminal itself is using continuous (RGB) colors. The modified code is now in CVS. It does not, however, fix the problem that if the palette uses only a limited number of colors (set palette maxcolors N) then these colors are assigned with even spacing over the whole range. If you would like to have finer color resolution in one specific part of the range, that's an issue. Ethan > > > > After playing around with non-linear discrete palettes like the one in your > > problem figures, I have become suspicious that the problem is more serious > > than just the resolution of the color box. The palette colors assigned to > > individual points are also wrong. That is, the bad coloring in the color box > > is a correct representation of the coloring assigned to elements of the plot. > > > > > Yes, I found that changing this colorbar code, it changes also the the > plot itself, perhaps because of the "set_color(gray);" line inside of the loop? > > > > Now it may be that the way I constructed a test palette is not a good way > > to do it. I'll show my test below. > > > > set palette defined (0 "purple", 1 "blue", \ > > 1 "blue", 2 "dark-green", \ > > 2 "dark-green", 4 "spring-green", \ > > 4 "spring-green", 8 "yellow", \ > > 8 "yellow", 16 "orange", \ > > 16 "orange", 32 "red" \ > > ) > > set xrange [0:32] > > set cbrange [0:32] > > set ytics 2 > > set cbtics 2 > > set grid y > > > > plot '+' using 1:1:1 with points lt 7 lc palette > > > > pause -1 > > > > # Limiting the number of colors makes it much worse, and clarifies that the > > # error comes from assigning colors to the palette in equal increments > > # rather that looking at the requested range boundaries: > > set palette maxcolors 7 > > replot > > > > > > So apparently one cannot create a discrete palette this way. > > Or at least you cannot create a discrete palette with unequal color ranges. > > Using "show palette palette 7" confirms this, I think. > > > > But maybe there's another way that works better. > > Perhaps you could create a palette by hand and load it using > > set palette file 'mypalette.dat' > > Unfortunately the documentation is not very helpful as to exactly how color > > ranges are assigned to colors that are read in from a file. > > > > What commands produced the palette in your problem case? > > > > I did something along this (I want to change colors exactly at > values 1,2.5,5,10,....200): > > set term png truecolor small size 770,610 > set out "|cat" > set pm3d map > s=-1.0 > d=200-(-1.0) > set palette defined ( 0.0 "#DDDDDD", (-0.01-s)/d "#DDDDDD", \ > (-0.01-s)/d "white", (1.0-s)/d "white", \ > (1.0-s)/d "#FFFF00", (2.5-s)/d "#FFFF00", \ > (2.5-s)/d "#C1FFB4", (5.0-s)/d "#C1FFB4", \ > (5.0-s)/d "#92E178", (10.0-s)/d "#92E178", \ > (10.0-s)/d "#6EC36E", (20.0-s)/d "#6EC36E", \ > (20.0-s)/d "#49913C", (30.0-s)/d "#49913C", \ > (30.0-s)/d "#577350", (40.0-s)/d "#577350", \ > (40.0-s)/d "#5050C8", (50.0-s)/d "#5050C8", \ > (50.0-s)/d "#6600AA", (100.0-s)/d "#6600AA", \ > (100.0-s)/d "#993399", (150.0-s)/d "#993399", \ > (150.0-s)/d "#AA3366", (199.99-s)/d "#AA3366", (200.0-s)/d "#FF66FF" ) > set cbrange [-1.0:200] > splot [:][:][:] '/tmp/mydata' matrix notitle > set output > > > > > > Ethan > > > > > >> > >> Ethan > >> > >>> > > > |