<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcPy Legend Implementation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583628#M73724</link>
    <description>&lt;P&gt;showHeading = &lt;SPAN class=""&gt;False&lt;/SPAN&gt; &lt;SPAN class=""&gt;# Turn off headers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Iterate through all layout elements to find the Legend element
for elm in lyt_cim.elements:
    if elm.name == "Legend":  # Legend name
        # Iterate through legend items
        for itm in elm.items:
            if itm.name == "Willful killing of civilians":  # Target specific layer
                itm.showLayerName = True  # Keep layer name visible
                itm.showHeading = False   # Turn off headers&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 15:43:25 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-02-10T15:43:25Z</dc:date>
    <item>
      <title>ArcPy Legend Implementation</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583455#M73720</link>
      <description>&lt;P&gt;When adding the legend to the layout, the legend displays both the label and the layer name which results in the legend showing duplicate names. I am also having trouble making items in the map not be visible in the legend, for example I don't want the "Incidents" layer to appear on the legend. To get around this I tried creating a custom style for the legend, but the issue with the duplicate names still exists. I know that the style is applied to some degree because other aspects like the legend title not showing up is still consistent with the style I made&lt;/P&gt;&lt;P&gt;This is the code for the legend:&lt;BR /&gt;# legend&lt;BR /&gt;legend_style_path = r"C:/Users/samir/AppData/Roaming/ESRI/ArcGISPro/Favorites.stylx"&lt;BR /&gt;style_name = arcpy.Describe(legend_style_path).baseName&lt;BR /&gt;legend_styles = p.listStyleItems(style_name, "Legend")&lt;BR /&gt;legend_style = legend_styles[0]&lt;BR /&gt;legend_x = 15&lt;BR /&gt;legend_y = 4&lt;BR /&gt;legend_width = 2.5&lt;BR /&gt;legend_height = 3.5&lt;/P&gt;&lt;P&gt;legend = lyt.createMapSurroundElement(&lt;BR /&gt;MakeRec_LL(legend_x, legend_y, legend_width, legend_height),&lt;BR /&gt;"Legend",&lt;BR /&gt;mf,&lt;BR /&gt;legend_style,&lt;BR /&gt;"Incident Legend"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;legend.applyStyleItem(legend_style)&lt;BR /&gt;legend.autoAdd = False&lt;BR /&gt;legend.elementWidth = legend_width&lt;BR /&gt;legend.elementHeight = legend_height&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2025 17:18:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583455#M73720</guid>
      <dc:creator>YahyaMasri</dc:creator>
      <dc:date>2025-02-09T17:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Legend Implementation</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583458#M73721</link>
      <description>&lt;P&gt;In the properties box for the legend- turn off Headers.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2025 18:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583458#M73721</guid>
      <dc:creator>Joseph_Darmiento</dc:creator>
      <dc:date>2025-02-09T18:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Legend Implementation</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583628#M73724</link>
      <description>&lt;P&gt;showHeading = &lt;SPAN class=""&gt;False&lt;/SPAN&gt; &lt;SPAN class=""&gt;# Turn off headers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Iterate through all layout elements to find the Legend element
for elm in lyt_cim.elements:
    if elm.name == "Legend":  # Legend name
        # Iterate through legend items
        for itm in elm.items:
            if itm.name == "Willful killing of civilians":  # Target specific layer
                itm.showLayerName = True  # Keep layer name visible
                itm.showHeading = False   # Turn off headers&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 15:43:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-legend-implementation/m-p/1583628#M73724</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-02-10T15:43:25Z</dc:date>
    </item>
  </channel>
</rss>

