Title: UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment · Issue #4900 · matplotlib/matplotlib · GitHub
Open Graph Title: UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment · Issue #4900 · matplotlib/matplotlib
X Title: UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment · Issue #4900 · matplotlib/matplotlib
Description: plt.clf() fig, ax = plt.subplots(1,2, sharey=True) plt.setp(ax.flat, aspect=1.0, adjustable='box-forced') #fig.set_size_inches(16,8) sns.despine(fig=fig) #scale = 'logit' scale = None plot.plot_year_dist(df_mesh[(df_mesh['Year'] >= min_y...
Open Graph Description: plt.clf() fig, ax = plt.subplots(1,2, sharey=True) plt.setp(ax.flat, aspect=1.0, adjustable='box-forced') #fig.set_size_inches(16,8) sns.despine(fig=fig) #scale = 'logit' scale = None plot.plot_yea...
X Description: plt.clf() fig, ax = plt.subplots(1,2, sharey=True) plt.setp(ax.flat, aspect=1.0, adjustable='box-forced') #fig.set_size_inches(16,8) sns.despine(fig=fig) #scale = 'logit' scale = No...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/4900
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment","articleBody":"``` python\nplt.clf()\nfig, ax = plt.subplots(1,2, sharey=True)\nplt.setp(ax.flat, aspect=1.0, adjustable='box-forced')\n#fig.set_size_inches(16,8)\nsns.despine(fig=fig)\n#scale = 'logit'\nscale = None\nplot.plot_year_dist(df_mesh[(df_mesh['Year'] \u003e= min_y) \u0026 (df_mesh['Year'] \u003c= 2009)],col='min_VolFirstP',col_label=\"Year\",thresh=10,file_prefix='individual_', ax=ax[0],color=sns.xkcd_rgb['black'],label='Individual Volume [%s-2009]' % min_y,marker=\"o\", scale = scale)\nplot.plot_year_dist(df[(df['Year'] \u003e= min_y) \u0026 (df['Year'] \u003c= 2009)],col='min_VolFirstP',col_label=\"Year\",thresh=10,file_prefix='pair_', ax=ax[0],color=sns.xkcd_rgb['red'],label='Pair Volume [%s-2009]' % min_y, marker=\"s\", scale = scale)\n\n\nplot.plot_year_dist(df_mesh[(df_mesh['Year'] \u003e= min_y) \u0026 (df_mesh['Year'] \u003c= 2009)],col='min_TFirstP',col_label=\"Years\",thresh=3,file_prefix='individual_', ax=ax[1],color=sns.xkcd_rgb['black'],label='Individual Time [%s-2009]' % min_y,marker=\"o\", scale = scale)\nplot.plot_year_dist(df[(df['Year'] \u003e= min_y) \u0026 (df['Year'] \u003c= 2009)],col='min_TFirstP',col_label=\"Years\",thresh=3,file_prefix='pair_', ax=ax[1],color=sns.xkcd_rgb['red'],label='Pair Time [%s-2009]' % min_y,marker=\"s\", scale = scale)\n\nfor i in range(2):\n ax[i].set_yscale(\"logit\", p_min=1e-4)\n ax[i].legend(bbox_to_anchor=(0., 1.02, 1., .102), borderaxespad=0., frameon=True, fancybox=True)\n\nplt.savefig(\"temp.pdf\",bbox_inches='tight')\n```\n\nWhen running the above code I am getting the following error:\n\n```\n---------------------------------------------------------------------------\nUnboundLocalError Traceback (most recent call last)\n\u003cipython-input-75-76bd951dfd46\u003e in \u003cmodule\u003e()\n 19 \n 20 \n---\u003e 21 plt.savefig(\"Novelty_year_dist_logit.pdf\",bbox_inches='tight')\n 22 plt.savefig(\"Novelty_year_dist_logit.eps\",bbox_inches='tight')\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.pyc in savefig(*args, **kwargs)\n 575 def savefig(*args, **kwargs):\n 576 fig = gcf()\n--\u003e 577 res = fig.savefig(*args, **kwargs)\n 578 draw() # need this if 'transparent=True' to reset colors\n 579 return res\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in savefig(self, *args, **kwargs)\n 1474 self.set_frameon(frameon)\n 1475 \n-\u003e 1476 self.canvas.print_figure(*args, **kwargs)\n 1477 \n 1478 if frameon:\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)\n 2156 orientation=orientation,\n 2157 dryrun=True,\n-\u003e 2158 **kwargs)\n 2159 renderer = self.figure._cachedRenderer\n 2160 bbox_inches = self.figure.get_tightbbox(renderer)\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.pyc in print_pdf(self, filename, **kwargs)\n 2483 RendererPdf(file, image_dpi),\n 2484 bbox_inches_restore=_bbox_inches_restore)\n-\u003e 2485 self.figure.draw(renderer)\n 2486 renderer.finalize()\n 2487 finally:\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)\n 57 def draw_wrapper(artist, renderer, *args, **kwargs):\n 58 before(artist, renderer)\n---\u003e 59 draw(artist, renderer, *args, **kwargs)\n 60 after(artist, renderer)\n 61 \n\n/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)\n 1083 dsu.sort(key=itemgetter(0))\n 1084 for zorder, a, func, args in dsu:\n-\u003e 1085 func(*args)\n 1086 \n 1087 renderer.close_group('figure')\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)\n 57 def draw_wrapper(artist, renderer, *args, **kwargs):\n 58 before(artist, renderer)\n---\u003e 59 draw(artist, renderer, *args, **kwargs)\n 60 after(artist, renderer)\n 61 \n\n/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)\n 2004 self.apply_aspect(pos)\n 2005 else:\n-\u003e 2006 self.apply_aspect()\n 2007 \n 2008 artists = []\n\n/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in apply_aspect(self, position)\n 1191 fig_aspect = figH / figW\n 1192 if self._adjustable in ['box', 'box-forced']:\n-\u003e 1193 if aspect_scale_mode == \"log\":\n 1194 box_aspect = A * self.get_data_ratio_log()\n 1195 else:\n\nUnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment\n```\n\nHowever, running the example explained in http://stackoverflow.com/a/13663328/1650159 doesn't give this error. \n\nAdditional Info:\n\n``` python\ndef plot_year_dist(df,col='',col_label=\"\",thresh=0,file_prefix='',outFolder=DEFAULT_OUTPUT,\\\n ax=None,color=sns.xkcd_rgb['black'],label='',scale=None,**kwargs):\n saveFig = False\n if ax is None:\n plt.clf()\n ax = plt.gca()\n saveFig = True\n filename = file_prefix+col+\"_year_dist.png\"\n df_g = df[[col,'Year']].groupby('Year').count()\n df_g[\"filtered\"] = df[[col,\"Year\"]][df[col] \u003c= thresh].groupby(\"Year\").count()\n df_g[\"prop\"] = df_g[\"filtered\"]/df_g[col]\n #print df_g.index\n #print df_g\n x = df_g.index.values\n y = df_g[\"prop\"].values\n if scale == 'logit':\n y = np.log10(y/(1.0-y))\n\n ax.plot(x,y, linestyle='-',markersize=3.0,color=color,label=label,**kwargs)\n\n print \"Finished generating histogram\"\n ax.set_xlabel(col_label)\n ax.set_ylabel(\"Proportion (\u003c= %s)\" % thresh)\n if scale == 'logit':\n ax.set_ylabel(\"$log_{10}(p/1-p)$ [$p = P(X\u003c= %s)$]\" % thresh)\n if saveFig:\n plt.savefig(outFolder+\"/\"+filename)\n print \"Plot saved in %s.\" % (filename)\n\n```\n","author":{"url":"https://github.com/napsternxg","@type":"Person","name":"napsternxg"},"datePublished":"2015-08-11T10:31:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/4900/matplotlib/issues/4900"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7835c0a3-4d5b-e395-e2b1-f2b942455443 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9794:14A013:BCCE7E:FB20A1:6A532116 |
| html-safe-nonce | b0ae54e7387b66300dfe87ccbd644254fb9ba1739a0e78271bf84c86b2d83648 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Nzk0OjE0QTAxMzpCQ0NFN0U6RkIyMEExOjZBNTMyMTE2IiwidmlzaXRvcl9pZCI6IjQzNTM0Njg2OTk0MzAyOTc4NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 070b651bd25ec01d2f59df1aa87f0e2c7abd8478dd689bb62705372fa471193d |
| hovercard-subject-tag | issue:100283033 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/4900/issue_layout |
| twitter:image | https://opengraph.githubassets.com/558284dc1acfcf734e36022c70057c20a458ecdf704e82be8c26c62bb440ca51/matplotlib/matplotlib/issues/4900 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/558284dc1acfcf734e36022c70057c20a458ecdf704e82be8c26c62bb440ca51/matplotlib/matplotlib/issues/4900 |
| og:image:alt | plt.clf() fig, ax = plt.subplots(1,2, sharey=True) plt.setp(ax.flat, aspect=1.0, adjustable='box-forced') #fig.set_size_inches(16,8) sns.despine(fig=fig) #scale = 'logit' scale = None plot.plot_yea... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | napsternxg |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width