2

To understand what was causing a legend title to be truncated from "What's on the map?" to "What's on the" in an ArcGIS Pro 2.1.3 layout I developed the test below:

  1. Start ArcGIS Pro
  2. Create a new project using Map.aptx called TestProject in a new folder under C:\Temp
  3. Add one layer to the map - in my test I used a countries shapefile (polygons) from Natural Earth but any shapefile or feature class should show this I think
  4. No matter what your layer is called name it ne_10m_admin_0_countries (or something with more characters in its name)
  5. Insert a Layout - I chose an A4 Portrait but any should be fine
  6. Insert a Map Frame - I chose the only Map and the one with a scale rather than the Default but either should be fine
  7. Make some room on the page for a legend under the map
  8. Insert a Legend and position it by dragging out its rectangle under the map
  9. Save the project and close ArcGIS Pro
  10. Use IDLE (or your preferred Python IDE) to run the script below

import arcpy,os
arcpy.env.overwriteOutput = True
aprx = arcpy.mp.ArcGISProject(r"C:\Temp\TestProject\TestProject.aprx")
lyt = aprx.listLayouts()[0]
legend = lyt.listElements('LEGEND_ELEMENT',"legend")[0]
legend.title = "What's on the map?"
legend.showTitle = True

lyt.exportToPDF(r"C:\Temp\test.pdf")
os.startfile(r"C:\Temp\test.pdf")

  1. On the PDF that opens the legend title of "What's on the map?" appears in full
  2. Close Adobe Acrobat Reader and the Python Shell window of IDLE to release any locks
  3. Open the TestProject on ArcGIS Pro again
  4. Rename the layer to Countries
  5. Save the project and close ArcGIS Pro
  6. Use IDLE (or your preferred Python IDE) to run the script again

This time when the PDF opens the legend title is truncated to "What's on the"

It appears that the length of the longest line of text next to the legend patches can restrict how many characters can appear the legend title.

Is this software behaviour documented anywhere?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.