[ROOT] Gradient Palette when drawing 2D histograms with "col" option

From: ANCIANT E. (eric.anciant@sodern.fr)
Date: Thu Mar 25 2004 - 14:19:34 MET

Hello rooters,

I have two questions concerning drawing 2D histograms using "col"
option, and a gradient palette.

It is illustrated by the macro below, when executing that macro :

1) Biny = 30, binx = 28,29  appear black, while they should be white,
this seems to be a bug.

2) I raise again the issue of drawing or not "content = 0.0" bins with
the "col" option. This issue has already been addressed in:


Yet, I don't understand the motivation of the given answer: NOT-drawing
bins with content = 0.0
(which can be seen in the source code line :
         if (z == 0) continue; // do not draw the empty bins
in : void THistPainter::PaintColorLevels(Option_t *)      )

This choice would make sense if histograms were filled only with
positive values, and if THistPainter::PaintColorLevels were used only by
this type
of histogram.

However bin's contents can be set, or filled, with negative values.
Moreover, THistPainter::PaintColorLevels method is also used to draw
other classes like TMatrix, for which the notion of "filling histogram
bins" has completely disappeared.

With the current choice, an histogram / mattrix whose content varies
from positive to negative values, with accidentally strict-zero values
is not drawn the right way (to my own opinion) as I tried to illustrate
by the macro below.




	/* USER PALETTE ************************/
	TColor *color;
	Int_t palette[50];
	int i,j;
	double Wcol;

	for (i=0;i<50;i++) {
		Wcol = Float_t(i)/49;
	    color = new TColor(501+i,Wcol,Wcol,Wcol,"");
		palette[i] = 501+i;

	/* Histogram with an iregular ramp from negative to positive
values */
	int i,j;
	TH2F h("h","h",30,0,30,30,0,30);

	double col = -15;
	for (j =0;j<5;j++) {
		for (i=0;i<30;i++) {
			col += 0.1;

// line j = 5 is left to 0's

	for (j =6;j<30;j++) {
		for (i=0;i<30;i++) {
			col += 0.1;
		col += 20;


	// this could be a workarround if the minimum value
	// in the histogram were 0's
	// but for minimum != 0, the patch becomes
	// strainiously complex

	TFrame* frame = (TFrame*)gPad->FindObject("TFrame");


Ce message et eventuellement les pieces jointes sont exclusivement transmis a l'usage de leur destinataire. Leur contenu est strictement confidentiel. Si vous n etes pas le bon destinataire nous vous demandons de ne pas conserver, copier, utiliser ou divulguer cette communication. Merci de le detruire et de me notifier cette erreur.

INTERNET ne permettant pas d assurer l integrite de ce message, SODERN decline toute responsabilite au cas ou il aurait ete intercepte ou modifie.

This message and possibly attachments are transmit for the exclusive use of their address. Their content is strictly confidential. If you are not the intended recipient please do not keep, copy, use or disclose this communication to others. Also please delete it and notify the sender at once.

Because of the nature of INTERNET the sender is not in a position to ensure the integrity of this message, therefore SODERN disclaims any liability whatoever in the event of this message having been intercepted and/or altered.

This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET