<?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: Export multiple charts with matplotlib in ArcPro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1255038#M66797</link>
    <description>&lt;P&gt;Do you get a specific error output?&lt;/P&gt;&lt;P&gt;Instead of plt.show() I would save the figure and then close the plot before proceeding to the next figure. Also, you might need to include the full path to the output folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;plt.legend()
plt.savefig(r"c:\path\figure.png")
plt.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 21:11:04 GMT</pubDate>
    <dc:creator>dslamb2022</dc:creator>
    <dc:date>2023-02-03T21:11:04Z</dc:date>
    <item>
      <title>Export multiple charts with matplotlib in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1254896#M66793</link>
      <description>&lt;P&gt;Hi I'm running a script from the python window in ArcPro 3.03 with the eventual aim of turning the script into a geoprocessing tool.&lt;/P&gt;&lt;P&gt;The script calculates scores for various criteria grouped in themes.&amp;nbsp; I then want to produce a chart for each theme, so six charts in total to be exported. The code works fine for one chart but when I add another after I save the first chart the script fails/crashes.&lt;/P&gt;&lt;P&gt;How can I export multiple charts using matplotlib in ArcPro?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Create radar chart for Thematic Layer B
arcpy.management.SelectLayerByAttribute("AUScores", "NEW_SELECTION", "CriteriaCode LIKE 'B%'", None)
fields = ["Criteria"]
categories = [i[0] for i in arcpy.da.SearchCursor(AUScores,fields[0])]
categories = [*categories, categories[0]]
fields = ["Scores_Int"]
scores = [i[0] for i in arcpy.da.SearchCursor(AUScores,fields[0])]
scores = [*scores, scores[0]]

label_loc = np.linspace(start=0, stop=2 * np.pi, num=len(scores))

plt.figure(figsize=(9, 9))
plt.subplot(polar=True)
plt.plot(label_loc, scores, label='Score', color = 'firebrick')
plt.title('Biodiversity Values', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend()
plt.show()
plt.savefig('BiodiversityValues.png')

#Create radar chart for Thematic Layer C
arcpy.management.SelectLayerByAttribute(AUScores, "CLEAR_SELECTION")
arcpy.management.SelectLayerByAttribute("AUScores", "NEW_SELECTION", "CriteriaCode LIKE 'C%'", None)
fields = ["Criteria"]
categories = [i[0] for i in arcpy.da.SearchCursor(AUScores,fields[0])]
categories = [*categories, categories[0]]
fields = ["Scores_Int"]
scores = [i[0] for i in arcpy.da.SearchCursor(AUScores,fields[0])]
scores = [*scores, scores[0]]

label_loc = np.linspace(start=0, stop=2 * np.pi, num=len(scores))

plt.figure(figsize=(9, 9))
plt.subplot(polar=True)
plt.plot(label_loc, scores, label='Score', color = 'firebrick')
plt.title('Human Use and Habitat Alteration', size=20)
lines, labels = plt.thetagrids(np.degrees(label_loc), labels=categories)
plt.legend()
plt.show()
plt.savefig('ImpactsAndAlteration.png')&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 16:30:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1254896#M66793</guid>
      <dc:creator>ChelseaVSmith</dc:creator>
      <dc:date>2023-02-03T16:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Export multiple charts with matplotlib in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1255038#M66797</link>
      <description>&lt;P&gt;Do you get a specific error output?&lt;/P&gt;&lt;P&gt;Instead of plt.show() I would save the figure and then close the plot before proceeding to the next figure. Also, you might need to include the full path to the output folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;plt.legend()
plt.savefig(r"c:\path\figure.png")
plt.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 21:11:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1255038#M66797</guid>
      <dc:creator>dslamb2022</dc:creator>
      <dc:date>2023-02-03T21:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export multiple charts with matplotlib in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1255101#M66799</link>
      <description>&lt;P&gt;I'd also instantiate a new plt object for each plot instead of reusing it, del'ing it after you save it.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 02:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-multiple-charts-with-matplotlib-in-arcpro/m-p/1255101#M66799</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-02-04T02:33:04Z</dc:date>
    </item>
  </channel>
</rss>

