## [Plplot-general] RGB mapping for plsmap1

 [Plplot-general] RGB mapping for plsmap1 From: Tune Kamae - 2004-12-05 04:27:07 ```Dear PLplot experts, I have been using PLplot through python/numarray to plot astronomical intensity maps in false color for 2 years. Ever since I wrote the first shaded contour plot, I have been wishing to improve the contrasts and the dynamic range of the Hue mapping. I came up with an inproved mapping using RGB (can also be in HSV) by making the function non0linear. This requires many reference points (eg. 20 points). Following the manual description on plshades and the python example xw11.py, I wrote the following cmap1_init_3D. But it doesn't work. I would appreciate any guidance or suggestion. T. Kamae, Stanford Linear Accelerator Center. ---------------------------------------------------------------------------- # Color map 1 in RGB space for plot3D # (from plplot/examples/python/xw11.py) def cmap1_init_3D(self, gray): """Routine for defining a specific color map 1 in RGB space. If gray is true, use basic grayscale variation from half-dark to light. Otherwise use a parameteized mapping to R(z), G(z), and B(z) where z=[0,1]. i=0 corresponds to z=1.0, the brightest color for this implementation. """ # Independent variable of control points. i = arange(0.0, 1.05, 0.05) if gray: # Red for control points. r = arange(241.0, 0.0, -12.0) # Green for control points. g = arange(241.0, 0.0, -12.0) # Blue for control points. b = arange(241.0, 0.0, -12.0) else: z=arange(1.0,1.05,0.05) z[20]=1.0 # Red for control points. r = 113.9*sin(7.64*z**1.705+0.701)-916.1*(z+1.755)**1.862\ +3587.9*z+2563.4 rr = clip(r,0.0,255.0) # Green for control points. g = 70.0*sin(8.7*z**1.26-2.418)+151.7*z**0.5+70.0 gg = clip(g,0.0,255.0) # Blue for control points. b = 194.5*z**2.88+99.72*exp(-77.24*(z-0.742)**2)\ +45.40*z**0.089+10.0 bb = clip(b,0.0,255.0) # Integer flag array is zero (no interpolation along far-side # of colour figure.) rev = array([0]+[1]*19+[0]) # number of cmap1 colours is 256 in this case. # smaller the number of colours, the clearer the z contour #plscmap1n(256) plscmap1n(21) # Interpolate between control points to set up cmap1. plscmap1l(1, i, rr, gg, bb, rev) ```

 [Plplot-general] RGB mapping for plsmap1 From: Tune Kamae - 2004-12-05 04:27:07 ```Dear PLplot experts, I have been using PLplot through python/numarray to plot astronomical intensity maps in false color for 2 years. Ever since I wrote the first shaded contour plot, I have been wishing to improve the contrasts and the dynamic range of the Hue mapping. I came up with an inproved mapping using RGB (can also be in HSV) by making the function non0linear. This requires many reference points (eg. 20 points). Following the manual description on plshades and the python example xw11.py, I wrote the following cmap1_init_3D. But it doesn't work. I would appreciate any guidance or suggestion. T. Kamae, Stanford Linear Accelerator Center. ---------------------------------------------------------------------------- # Color map 1 in RGB space for plot3D # (from plplot/examples/python/xw11.py) def cmap1_init_3D(self, gray): """Routine for defining a specific color map 1 in RGB space. If gray is true, use basic grayscale variation from half-dark to light. Otherwise use a parameteized mapping to R(z), G(z), and B(z) where z=[0,1]. i=0 corresponds to z=1.0, the brightest color for this implementation. """ # Independent variable of control points. i = arange(0.0, 1.05, 0.05) if gray: # Red for control points. r = arange(241.0, 0.0, -12.0) # Green for control points. g = arange(241.0, 0.0, -12.0) # Blue for control points. b = arange(241.0, 0.0, -12.0) else: z=arange(1.0,1.05,0.05) z[20]=1.0 # Red for control points. r = 113.9*sin(7.64*z**1.705+0.701)-916.1*(z+1.755)**1.862\ +3587.9*z+2563.4 rr = clip(r,0.0,255.0) # Green for control points. g = 70.0*sin(8.7*z**1.26-2.418)+151.7*z**0.5+70.0 gg = clip(g,0.0,255.0) # Blue for control points. b = 194.5*z**2.88+99.72*exp(-77.24*(z-0.742)**2)\ +45.40*z**0.089+10.0 bb = clip(b,0.0,255.0) # Integer flag array is zero (no interpolation along far-side # of colour figure.) rev = array([0]+[1]*19+[0]) # number of cmap1 colours is 256 in this case. # smaller the number of colours, the clearer the z contour #plscmap1n(256) plscmap1n(21) # Interpolate between control points to set up cmap1. plscmap1l(1, i, rr, gg, bb, rev) ```
 Re: [Plplot-general] RGB mapping for plsmap1 From: Curtis Cooper - 2004-12-05 05:37:16 ```I think the PLplot colormap setting functions expect color ranges clamped between [0,1]. Cheers, Curtis * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Curtis S. Cooper, Graduate Research Assistant * * Lunar and Planetary Laboratory, University of Arizona * * http://www.lpl.arizona.edu/~curtis/ * * Kuiper Space Sciences, Rm. 318 * * 1629 E. University Blvd., * * Tucson, AZ 85721 * * * * * * * * * * * * * * * * Wk: (520) 621-1471 * * * * * * * * * * * * * On Sat, 4 Dec 2004, Tune Kamae wrote: > Dear PLplot experts, > > I have been using PLplot through python/numarray to plot > astronomical intensity maps in false color for 2 years. > Ever since I wrote the first shaded contour plot, I have > been wishing to improve the contrasts and the dynamic > range of the Hue mapping. I came up with an inproved > mapping using RGB (can also be in HSV) by making > the function non0linear. This requires many reference > points (eg. 20 points). > > Following the manual description on plshades and > the python example xw11.py, I wrote the following > cmap1_init_3D. But it doesn't work. > > I would appreciate any guidance or suggestion. > > T. Kamae, Stanford Linear Accelerator Center. > > ---------------------------------------------------------------------------- > # Color map 1 in RGB space for plot3D > # (from plplot/examples/python/xw11.py) > > def cmap1_init_3D(self, gray): > """Routine for defining a specific color map 1 in > RGB space. If gray is true, use basic grayscale > variation from half-dark to light. Otherwise use > a parameteized mapping to R(z), G(z), and B(z) where > z=[0,1]. i=0 corresponds to z=1.0, the brightest > color for this implementation. > """ > > # Independent variable of control points. > i = arange(0.0, 1.05, 0.05) > if gray: > # Red for control points. > r = arange(241.0, 0.0, -12.0) > # Green for control points. > g = arange(241.0, 0.0, -12.0) > # Blue for control points. > b = arange(241.0, 0.0, -12.0) > else: > z=arange(1.0,1.05,0.05) > z[20]=1.0 > # Red for control points. > r = 113.9*sin(7.64*z**1.705+0.701)-916.1*(z+1.755)**1.862\ > +3587.9*z+2563.4 > rr = clip(r,0.0,255.0) > # Green for control points. > g = 70.0*sin(8.7*z**1.26-2.418)+151.7*z**0.5+70.0 > gg = clip(g,0.0,255.0) > # Blue for control points. > b = 194.5*z**2.88+99.72*exp(-77.24*(z-0.742)**2)\ > +45.40*z**0.089+10.0 > bb = clip(b,0.0,255.0) > > # Integer flag array is zero (no interpolation along far-side > # of colour figure.) > rev = array([0]+[1]*19+[0]) > # number of cmap1 colours is 256 in this case. > # smaller the number of colours, the clearer the z contour > #plscmap1n(256) > plscmap1n(21) > # Interpolate between control points to set up cmap1. > plscmap1l(1, i, rr, gg, bb, rev) > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Plplot-general mailing list > Plplot-general@... > https://lists.sourceforge.net/lists/listinfo/plplot-general > ```
 Re: [Plplot-general] RGB mapping for plsmap1 From: Alan W. Irwin - 2004-12-05 06:24:58 ```On 2004-12-04 22:37-0700 Curtis Cooper wrote: > I think the PLplot colormap setting functions expect color ranges clamped > between [0,1]. > > Cheers, > Curtis > On Sat, 4 Dec 2004, Tune Kamae wrote: > >> Dear PLplot experts, >> >> z=arange(1.0,1.05,0.05) ^^^ Tune, following up on what Curtis said, any number in the range 0 --> 1 including those end-points is okay. But the above gives on my platform the two-point array [ 1. 1.05] which is clearly out of bounds. Alternatively, for slightly different floating-point rounding it would only give you [1.] which I don't think you want. I think you meant 0.0 for the lower limit which gives on my platform [ 0. 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1. ] Which should be fine so long as some stray round-off error doesn't change that 1.0 to 1.0+eps or else stick on an extra 1.05 value at the upper limit. The 1.0 to 0.0 change might make your logic work, but better yet, I would keep the floating point logic to a minimum, that is, use integer arrays (to make sure you get the correct number of values exactly), convert them to floating point by multiplying by 0.05, then redefine the upper end (as you do already) to make sure. z = 0.05*arange(21) z[20]=1. HTH. Alan __________________________ Alan W. Irwin email: irwin@... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ```
 Re: [Plplot-general] RGB mapping for plsmap1 From: Tune Kamae - 2004-12-05 07:11:40 ```Curtis, Thank you for the prompt response. Yes, it is now working. Many thanks for your advice. Tune Kamae ----- Original Message ----- From: "Curtis Cooper" To: "Tune Kamae" Cc: Sent: Saturday, December 04, 2004 9:37 PM Subject: Re: [Plplot-general] RGB mapping for plsmap1 > I think the PLplot colormap setting functions expect color ranges clamped > between [0,1]. > > Cheers, > Curtis > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * Curtis S. Cooper, Graduate Research Assistant * > * Lunar and Planetary Laboratory, University of Arizona * > * http://www.lpl.arizona.edu/~curtis/ * > * Kuiper Space Sciences, Rm. 318 * > * 1629 E. University Blvd., * > * Tucson, AZ 85721 * * * * * * * * * * * * * * * > * Wk: (520) 621-1471 * > * * * * * * * * * * * * > > On Sat, 4 Dec 2004, Tune Kamae wrote: > > > Dear PLplot experts, > > > > I have been using PLplot through python/numarray to plot > > astronomical intensity maps in false color for 2 years. > > Ever since I wrote the first shaded contour plot, I have > > been wishing to improve the contrasts and the dynamic > > range of the Hue mapping. I came up with an inproved > > mapping using RGB (can also be in HSV) by making > > the function non0linear. This requires many reference > > points (eg. 20 points). > > > > Following the manual description on plshades and > > the python example xw11.py, I wrote the following > > cmap1_init_3D. But it doesn't work. > > > > I would appreciate any guidance or suggestion. > > > > T. Kamae, Stanford Linear Accelerator Center. > > > > -------------------------------------------------------------------------- -- > > # Color map 1 in RGB space for plot3D > > # (from plplot/examples/python/xw11.py) > > > > def cmap1_init_3D(self, gray): > > """Routine for defining a specific color map 1 in > > RGB space. If gray is true, use basic grayscale > > variation from half-dark to light. Otherwise use > > a parameteized mapping to R(z), G(z), and B(z) where > > z=[0,1]. i=0 corresponds to z=1.0, the brightest > > color for this implementation. > > """ > > > > # Independent variable of control points. > > i = arange(0.0, 1.05, 0.05) > > if gray: > > # Red for control points. > > r = arange(241.0, 0.0, -12.0) > > # Green for control points. > > g = arange(241.0, 0.0, -12.0) > > # Blue for control points. > > b = arange(241.0, 0.0, -12.0) > > else: > > z=arange(1.0,1.05,0.05) > > z[20]=1.0 > > # Red for control points. > > r = 113.9*sin(7.64*z**1.705+0.701)-916.1*(z+1.755)**1.862\ > > +3587.9*z+2563.4 > > rr = clip(r,0.0,255.0) > > # Green for control points. > > g = 70.0*sin(8.7*z**1.26-2.418)+151.7*z**0.5+70.0 > > gg = clip(g,0.0,255.0) > > # Blue for control points. > > b = 194.5*z**2.88+99.72*exp(-77.24*(z-0.742)**2)\ > > +45.40*z**0.089+10.0 > > bb = clip(b,0.0,255.0) > > > > # Integer flag array is zero (no interpolation along far-side > > # of colour figure.) > > rev = array([0]+[1]*19+[0]) > > # number of cmap1 colours is 256 in this case. > > # smaller the number of colours, the clearer the z contour > > #plscmap1n(256) > > plscmap1n(21) > > # Interpolate between control points to set up cmap1. > > plscmap1l(1, i, rr, gg, bb, rev) > > > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://productguide.itmanagersjournal.com/ > > _______________________________________________ > > Plplot-general mailing list > > Plplot-general@... > > https://lists.sourceforge.net/lists/listinfo/plplot-general > > > > ```