<?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: PYTHON: My layer appears 3 times in my legend. Can't change it with arcpy  but Idon't know why... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667192#M74932</link>
    <description>&lt;P&gt;I don't have an answer, I don't really like working with legends and python, there a pain in my opinion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure someone will have an idea.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Nov 2025 16:24:28 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-11-19T16:24:28Z</dc:date>
    <item>
      <title>PYTHON: My layer appears 3 times in my legend. Can't change it with arcpy  but Idon't know why...</title>
      <link>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667146#M74927</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I developed a Python script to automate the generation of maps in ArcGIS Pro based on various parameters.&lt;/P&gt;&lt;P&gt;In my layout, I want to be able to modify the LEGEND_Item, but all my attempts have failed so far...&lt;/P&gt;&lt;P&gt;In fact, in my legend, I only want one layer to appear, while the others should be hidden (in the legend only).&lt;/P&gt;&lt;P&gt;My code does allow me to hide the layers I don’t want in the legend, but the one I do want appears &lt;STRONG&gt;3&lt;/STRONG&gt; times in the legend. I should mention that it is inserted only once in the map. Its symbology is based on unique values, and there are &lt;STRONG&gt;3&lt;/STRONG&gt; unique values. I suspect this is related.&lt;/P&gt;&lt;P&gt;Here's my code and the result:&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;legend = "LEGENDE_" + NOMCARTE&lt;BR /&gt;lyt_legend = lyt.listElements("LEGEND_ELEMENT", legend)[0]&lt;BR /&gt;lyt_legend.title = "" # Met le titre à vide&lt;BR /&gt;logging.info("Titre de la légende effacé.")&lt;/P&gt;&lt;P&gt;except IndexError:&lt;BR /&gt;logging.error(f"Légende introuvable dans le layout : {legend_name}")&lt;BR /&gt;except Exception as e:&lt;BR /&gt;logging.error(f"Erreur inattendue : {str(e)}")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;try:&lt;BR /&gt;couches_a_masquer = [DEPT_lyr.name, COMM_lyr.name, DEPT_mask_lyr.name, "COMMUNES_TRONCONS_SpatJoin"]&lt;/P&gt;&lt;P&gt;for item in lyt_legend.items:&lt;BR /&gt;if item.name in couches_a_masquer:&lt;BR /&gt;item.visible = False&lt;BR /&gt;logging.info(f"Élément de légende masqué : {item.name}")&lt;BR /&gt;except IndexError:&lt;BR /&gt;logging.error(f"Légende introuvable dans le layout : {legend}")&lt;BR /&gt;except Exception as e:&lt;BR /&gt;logging.error(f"Erreur inattendue lors de la mise à jour de la légende : {str(e)}")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="magdatopa_ratp_0-1763564336307.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144093iED7F12AE4D3F0F6B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="magdatopa_ratp_0-1763564336307.png" alt="magdatopa_ratp_0-1763564336307.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also want to get rid of the label "EVOL" and change the text for each value (ex. 0 should be replaced by "Unchanged value".&lt;/P&gt;&lt;P&gt;Any idea on how to do it if possible?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667146#M74927</guid>
      <dc:creator>magdatopa_ratp</dc:creator>
      <dc:date>2025-11-19T15:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON: My layer appears 3 times in my legend. Can't change it with arcpy  but Idon't know why...</title>
      <link>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667159#M74929</link>
      <description>&lt;P&gt;Your symbology is unique values, so the legend automatically lists each unique value as a separate legend item. Try&amp;nbsp;changing the labels for each unique value (0 → "Unchanged value", etc.),&amp;nbsp;showHeading = False - Hides the layer name ("EVOL" in your case).&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667159#M74929</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-11-19T15:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON: My layer appears 3 times in my legend. Can't change it with arcpy  but Idon't know why...</title>
      <link>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667169#M74930</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3265"&gt;@TonyAlmeida&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for answering so fast.&lt;/P&gt;&lt;P&gt;That exactly what I suspected : the legend displays each unique value as a separate legend item.&lt;/P&gt;&lt;P&gt;I'll try changing the labels for each unique value but once it is done, do you know if&amp;nbsp; there is&amp;nbsp; a way to get a result that looks like that? (just one item displayed in the legend)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="magdatopa_ratp_0-1763567001023.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/144101i03D81EFC951062E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="magdatopa_ratp_0-1763567001023.png" alt="magdatopa_ratp_0-1763567001023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667169#M74930</guid>
      <dc:creator>magdatopa_ratp</dc:creator>
      <dc:date>2025-11-19T15:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON: My layer appears 3 times in my legend. Can't change it with arcpy  but Idon't know why...</title>
      <link>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667192#M74932</link>
      <description>&lt;P&gt;I don't have an answer, I don't really like working with legends and python, there a pain in my opinion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure someone will have an idea.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 16:24:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-my-layer-appears-3-times-in-my-legend-can-t/m-p/1667192#M74932</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-11-19T16:24:28Z</dc:date>
    </item>
  </channel>
</rss>

