# vtkPointSetToLabelHierarchy labels not being displayed

**URL:** https://discourse.paraview.org/t/vtkpointsettolabelhierarchy-labels-not-being-displayed/10732
**Category:** ParaView Support
**Created:** [November 11, 2022, 10:38pm UTC](https://discourse.paraview.org/t/vtkpointsettolabelhierarchy-labels-not-being-displayed/10732 "2022-11-11T22:38:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Kischell](https://discourse.paraview.org/user_avatar/discourse.paraview.org/eric_kischell/32/10372_2.png) [@Eric\_Kischell](https://discourse.paraview.org/u/Eric_Kischell)
#### Post date: [November 11, 2022, 10:38pm UTC](https://discourse.paraview.org/t/vtkpointsettolabelhierarchy-labels-not-being-displayed/10732/1 "2022-11-11T22:38:56Z")

</div>

Hello,  
I have a nice polygonal anatomical model exported to VTP format.  
Paraview is employed to help visualize the surface model.  
All is well.

I wish to add labels to certain “key points” or possibly specific cells.  
I tried following the example–  
[https://kitware.github.io/vtk-examples/site/Cxx/Visualization/LabelPlacementMapper/](https://kitware.github.io/vtk-examples/site/Cxx/Visualization/LabelPlacementMapper/)  
But I am still missing a concept as the labels are not visible near their points under Paraview.  
Any ideas would be appreciated.|

```auto
// Create a point set.
	int NUM_PTS = 24;
	vtkNew<vtkPointSource> pointSource;
	pointSource->SetNumberOfPoints(NUM_PTS);
	pointSource->Update();

	vtkSmartPointer<vtkStringArray> labels = vtkSmartPointer<vtkStringArray>::New();
	vtkSmartPointer<vtkIntArray> sizes = vtkSmartPointer<vtkIntArray>::New();
	vtkSmartPointer<vtkPointSetToLabelHierarchy> pointSetToLabelHierarchyFilter = vtkSmartPointer<vtkPointSetToLabelHierarchy>::New();
	vtkSmartPointer<vtkCellArray> celldata = vtkSmartPointer<vtkCellArray>::New();
	vtkSmartPointer<vtkFloatArray> scalars = vtkSmartPointer<vtkFloatArray>::New();
	vtkSmartPointer<vtkTextProperty> textprop = vtkSmartPointer<vtkTextProperty>::New();

	// Add label array
	labels->SetNumberOfValues(NUM_PTS);
	labels->SetName("labels");
	// Add priority array
	sizes->SetNumberOfValues(NUM_PTS);
	sizes->SetName("sizes");
	for (vtkIdType i = 0; i < NUM_PTS; i++)
	{
		labels->SetValue(i, std::string("My Label ") + std::to_string(i));
		sizes->SetValue(i, i);
	}
	pointSource->GetOutput()->GetPointData()->AddArray(labels);
	pointSource->GetOutput()->GetPointData()->AddArray(sizes);

	vtkPoints* points = pointSource->GetOutput()->GetPoints();	
	for (vtkIdType id = 0; id < points->GetNumberOfPoints(); id++)
	{
		scalars->InsertValue(id, float(id*10));
		celldata->InsertNextCell(1);
		celldata->InsertCellPoint(id);
	}

	vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
	polydata->SetPoints(points);
	polydata->SetVerts(celldata);
	polydata->GetPointData()->SetScalars(scalars);
	polydata->GetPointData()->AddArray(labels);
	polydata->GetPointData()->AddArray(sizes);
	polydata->BuildCells();

	pointSetToLabelHierarchyFilter->SetInputData(polydata);
	pointSetToLabelHierarchyFilter->SetLabelArrayName("labels");
	pointSetToLabelHierarchyFilter->SetPriorityArrayName("sizes");
	pointSetToLabelHierarchyFilter->Update();

	vtkSmartPointer<vtkXMLPolyDataWriter> writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
	writer->SetFileName("Y:\\data\\test_vtk_labels.vtp");
	writer->SetInputData(polydata);
	writer->SetDataModeToBinary(); // or writer->SetDataModeToAscii();
	writer->Write();

```

 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/6a4ea8cde74ceaee63caa0e8418ca755f50c26b5.png)
