Zooming a plot of 4 superimposed histos

In visualising hits in a event, I try to use the following code. The idea is to have in the same histogram, the origin of a track (black dot), the first hit in a detector (red dot) and the second hit (blue dot). Also, I want to mark a cube (i.e. 12 lines), like a box, around the origin.
The following code does that; however, when I have the plot and want to zoom in by selecting a region with the mouse, it all goes wrong. Parts of the plot move, others don’t and the relative positions go wrong. I guess this is because there are 4 TH3D plots on top of each other and only some of them scale, or something. How can I avoid that and still have only one plot with different colours (and marker styles) for different points?

	TH3D* h3d = new TH3D("h3d", "h3d", 100, hmin, hmax, 100, hmin, hmax, 50, hminz, hmaxz);	
	TH3D* h3d_2 = h3d->Clone();
	TH3D* h3d_3 = h3d->Clone();
	TH3D* h3d_4 = h3d->Clone();

	h3d->Fill(source_x, source_y, source_z);
	h3d->SetMarkerColor(kBlack);
	h3d->SetMarkerSize(1);
	h3d->SetMarkerStyle(20);
	h3d->Draw("P");

	h3d_2->Fill(hitabs_x, hitabs_y, hitabs_z);
	h3d_2->SetMarkerColor(kRed);
	h3d_2->SetMarkerSize(1);
	h3d_2->SetMarkerStyle(20);
	h3d_2->DrawClone("P SAME");
	
	h3d_3->Fill(hitscat_x, hitscat_y, hitscat_z);
	h3d_3->SetMarkerColor(kBlue);
	h3d_3->SetMarkerSize(1);
	h3d_3->SetMarkerStyle(20);
	h3d_3->DrawClone("P SAME");

	/*
	TPolyLine3D* axisFov1 = new TPolyLine3D(6);	
	axisFov1->SetLineColor(kBlack);
	axisFov1->SetLineWidth(1);
 	axisFov1->SetPoint(0, fov_x_min, fov_y_min, fov_z_min);
 	axisFov1->SetPoint(1, fov_x_max, fov_y_min, fov_z_min);
              // etc ...
	axisFov1->Draw("SAME");
	*/

	double x = fov_x_min; double delx = (fov_x_max - fov_x_min)/100;
	double y = fov_y_min; double dely = (fov_y_max - fov_y_min)/100;
	double z = fov_z_min; double delz = (fov_z_max - fov_z_min)/100;
	for (int istep = 0; istep < 100; istep++)
	{
		h3d_4->Fill(x, fov_y_min, fov_z_min);	
		h3d_4->Fill(x, fov_y_max, fov_z_min);	
		h3d_4->Fill(x, fov_y_min, fov_z_max);	
		h3d_4->Fill(x, fov_y_max, fov_z_max);	

		h3d_4->Fill(fov_x_min, y, fov_z_min);	
		h3d_4->Fill(fov_x_max, y, fov_z_min);	
		h3d_4->Fill(fov_x_min, y, fov_z_max);	
		h3d_4->Fill(fov_x_max, y, fov_z_max);	

		h3d_4->Fill(fov_x_min, fov_y_min, z);	
		h3d_4->Fill(fov_x_max, fov_y_min, z);	
		h3d_4->Fill(fov_x_min, fov_y_max, z);	
		h3d_4->Fill(fov_x_max, fov_y_max, z);	

		x += delx;
		y += dely;
		z += delz;
	}
	h3d_4->SetMarkerColor(kBlack);
	h3d_4->DrawClone("SAME");

can you provide a running example ? (the data are missing in what you sent)

Ok. The entire code is here:

TCanvas* m_c1 = NULL;

int VisualiseEvent()
{
	m_c1 = new TCanvas("m_c1", "m_c1", 600, 600);
	
	double hitabs_x = 100; 
	double hitabs_y = 0; 
	double hitabs_z = 240;

	double hitscat_x = 100; 
	double hitscat_y = 0; 
	double hitscat_z = 110;

	double source_x = 0;
	double source_y = 0;
	double source_z = 0;

	double fov_x_min = -10;
	double fov_x_max = 10;
	double fov_y_min = -10;
	double fov_y_max = 10;
	double fov_z_min = -10;
	double fov_z_max = 10;
	
	double hmin = -150;
	double hmax = 150;
	double hminz = -10;
	double hmaxz = 250;
	
	TH3D* h3d = new TH3D("h3d", "h3d", 300, hmin, hmax, 300, hmin, hmax, 260, hminz, hmaxz);	
	TH3D* h3d_2 = h3d->Clone();
	TH3D* h3d_3 = h3d->Clone();
	TH3D* h3d_4 = h3d->Clone();

	h3d->Fill(source_x, source_y, source_z);
	h3d->SetMarkerColor(kRed);
	h3d->SetMarkerSize(1);
	h3d->SetMarkerStyle(20);
	h3d->DrawCopy("P");

	h3d_2->Fill(hitabs_x, hitabs_y, hitabs_z);
	h3d_2->SetMarkerColor(kRed);
	h3d_2->SetMarkerSize(1);
	h3d_2->SetMarkerStyle(20);
	h3d_2->DrawClone("P SAME");
	
	h3d_3->Fill(hitscat_x, hitscat_y, hitscat_z);
	h3d_3->SetMarkerColor(kBlue);
	h3d_3->SetMarkerSize(1);
	h3d_3->SetMarkerStyle(20);
	h3d_3->DrawClone("P SAME");

	double x = fov_x_min; double delx = (fov_x_max - fov_x_min)/100;
	double y = fov_y_min; double dely = (fov_y_max - fov_y_min)/100;
	double z = fov_z_min; double delz = (fov_z_max - fov_z_min)/100;

	for (int istep = 0; istep < 100; istep++)
	{
		h3d_4->Fill(x, fov_y_min, fov_z_min);	
		h3d_4->Fill(x, fov_y_max, fov_z_min);	
		h3d_4->Fill(x, fov_y_min, fov_z_max);	
		h3d_4->Fill(x, fov_y_max, fov_z_max);	

		h3d_4->Fill(fov_x_min, y, fov_z_min);	
		h3d_4->Fill(fov_x_max, y, fov_z_min);	
		h3d_4->Fill(fov_x_min, y, fov_z_max);	
		h3d_4->Fill(fov_x_max, y, fov_z_max);	

		h3d_4->Fill(fov_x_min, fov_y_min, z);	
		h3d_4->Fill(fov_x_max, fov_y_min, z);	
		h3d_4->Fill(fov_x_min, fov_y_max, z);	
		h3d_4->Fill(fov_x_max, fov_y_max, z);	

		x += delx;
		y += dely;
		z += delz;
	}
	h3d_4->SetMarkerColor(kBlack);
	h3d_4->SetMarkerStyle(0);
	h3d_4->DrawCopy("");

	return 0;
}

I am not sure TH3s are the best approach to visualize events… it is quite an heavy way to do it.
I tried to execute your macro. It shows a back cube. Seems to me I can zoom it correctly (despite the fact it is very slow). I am using the trunk version of root on Mac.