<?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: matplotlib show() prevents script from completing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449593#M35202</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps run the plotting as a separate script via a subprocess.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Oct 2016 19:28:36 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2016-10-28T19:28:36Z</dc:date>
    <item>
      <title>matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449589#M35198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script tool that creates a graph using matplotlib. I use plt.show() to display the graph, but the script does not continue until I close the window. Thanks to &lt;A href="https://community.esri.com/migrated-users/3116" target="_blank"&gt;Dan Patterson&lt;/A&gt;‌ and&amp;nbsp;&lt;A href="https://community.esri.com/blogs/dan_patterson/2014/08/19/x-y-graphing-demo-using-pyplot-matplotliban-introduction?sr=search&amp;amp;searchId=99b9fb58-732a-45c0-955a-6ec7c2a037ec&amp;amp;searchIndex=0" target="_blank"&gt;/blogs/dan_patterson/2014/08/19/x-y-graphing-demo-using-pyplot-matplotliban-introduction?sr=search&amp;amp;searchId=99b9fb58-732a-45c0-955a-6ec7c2a037ec&amp;amp;searchIndex=0&lt;/A&gt;‌ I found&amp;nbsp;plt.close(), but is there a way to allow the script to continue while keeping the plot window open?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; matplotlib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;pyplot &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; plt

&lt;SPAN class="comment token"&gt;#Processing Step&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Create Graph&lt;/SPAN&gt;
tName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"tableLocation.txt"&lt;/SPAN&gt;
outputFile &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"outputFigure.png"&lt;/SPAN&gt;

x &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
y &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; 

&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; line &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parts &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; line&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;","&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parts&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;parts&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

fig &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;figure&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;plot&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;x&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; y&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;xlabel&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Distance'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ylabel&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Elevation'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fig&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;suptitle&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Graph Title"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;show&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fig&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;savefig&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;outputFile&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Next Processing Step&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:04:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449589#M35198</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2021-12-11T20:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449590#M35199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe I should have dug a little deeper before asking, but it looks like this is the solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;plt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;show&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;block&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now that works, I get a RunTime Error and ArcMap crashes when I interact with the graph (Click window or close).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 14:59:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449590#M35199</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2016-10-28T14:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449591#M35200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;plt.close()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 15:56:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449591#M35200</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-28T15:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449592#M35201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking at the &lt;A href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show"&gt;&lt;SPAN style="font-family: courier new,courier,monospace;"&gt;matplotlib.pyplot.show&lt;/SPAN&gt;&lt;/A&gt; documention:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="text-align: left; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: -0.14px; font-family: 'Helvetica Neue', Helvetica, 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;A single experimental keyword argument,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;EM style="text-align: left; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: -0.14px; font-family: monospace; font-size: 14px; font-weight: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;block&lt;/EM&gt;&lt;SPAN style="text-align: left; color: #333333; text-transform: none; text-indent: 0px; letter-spacing: -0.14px; font-family: 'Helvetica Neue', Helvetica, 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;, may be set to True or False to override the blocking behavior described above.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;ArcMap bug or experimental keyword not working?&amp;nbsp; I assume the experimental keyword doesn't crash all other apps all the time, so maybe open a bug report with Esri Support.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 18:02:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449592#M35201</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-10-28T18:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449593#M35202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps run the plotting as a separate script via a subprocess.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 19:28:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449593#M35202</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-10-28T19:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449594#M35203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmmm some better options... to test but here is a link... I will copy a few for posterity since they are on github&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://central.scipy.org/item/84/1/simple-interactive-matplotlib-plots" title="http://central.scipy.org/item/84/1/simple-interactive-matplotlib-plots"&gt;http://central.scipy.org/item/84/1/simple-interactive-matplotlib-plots&lt;/A&gt;&amp;nbsp;by Thomas Haslawanter 2015&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2016 00:11:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449594#M35203</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-11-05T00:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: matplotlib show() prevents script from completing</title>
      <link>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449595#M35204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all of the suggestions. I decided&amp;nbsp;not to show the chart through the matplotlib module. Since the features within that window were limited I saved it out as an image, and opened it in the default picture viewer. This allowed the process to complete without being held up by the chart window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2016 19:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/matplotlib-show-prevents-script-from-completing/m-p/449595#M35204</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2016-11-29T19:09:59Z</dc:date>
    </item>
  </channel>
</rss>

