Title: Cannot pickle `figure` or `axes` (TypeError: instancemethod) · Issue #3392 · matplotlib/matplotlib · GitHub
Open Graph Title: Cannot pickle `figure` or `axes` (TypeError: instancemethod) · Issue #3392 · matplotlib/matplotlib
X Title: Cannot pickle `figure` or `axes` (TypeError: instancemethod) · Issue #3392 · matplotlib/matplotlib
Description: Couple of issues I've found. def latex_float(f, pos=0): float_str = "{0:.2g}".format(f) if "e" in float_str: base, exponent = float_str.split("e") return r"${0} \times 10^{{{1}}}$".format(base, int(exponent)) else: return r"${}$".format(...
Open Graph Description: Couple of issues I've found. def latex_float(f, pos=0): float_str = "{0:.2g}".format(f) if "e" in float_str: base, exponent = float_str.split("e") return r"${0} \times 10^{{{1}}}$".format(base, int...
X Description: Couple of issues I've found. def latex_float(f, pos=0): float_str = "{0:.2g}".format(f) if "e" in float_str: base, exponent = float_str.split("e") return r"${...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/3392
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot pickle `figure` or `axes` (TypeError: instancemethod)","articleBody":"Couple of issues I've found.\n\n``` python\ndef latex_float(f, pos=0):\n float_str = \"{0:.2g}\".format(f)\n if \"e\" in float_str:\n base, exponent = float_str.split(\"e\")\n return r\"${0} \\times 10^{{{1}}}$\".format(base, int(exponent))\n else:\n return r\"${}$\".format(float_str)\n\nformatter = FuncFormatter(latex_float)\n\ncorr = np.corrcoef(data['x'], data['y'])[0,1]\nfig, ax = pl.subplots(figsize=figsize)\nhist, _, _, im = ax.hist2d(data['x'], data['y'], norm=LogNorm(), bins=(bins_x, bins_y) , alpha=0.75, cmap = cmap)\n\ncbar = fig.colorbar(im, ticks=[0., 1., 2., 5., 10., 20., 50., 100., 200., 500., 1000., 2000., 5000.], format=formatter)\ncbar.set_label('number density', fontsize=labelsize, labelpad=79)\ncbar.ax.tick_params(labelsize=labelsize-6, width=3, length=15)\ncbar.ax.minorticks_on()\n\nax.set_xlabel(label_x, fontsize=labelsize)\nax.set_ylabel(label_y, fontsize=labelsize)\nax.grid(True, which='both', linewidth=3, linestyle='--', alpha=0.5)\nax.text(0.95, 0.05, '$\\mathrm{{Corr}} = {:0.4f}$'.format(corr), transform=ax.transAxes, fontsize=labelsize, verticalalignment='bottom', horizontalalignment='right', bbox=textprops)\n\nax.tick_params(axis='both', which='major', labelsize=labelsize-6)\n\npickle.dump(ax, file('ZH_ax.pkl', 'w+'))\n\nfig.close()\n```\n\nAs it is, the code gives the following error:\n\n```\nTraceback (most recent call last):\n File \"make_plots_new.py\", line 124, in \u003cmodule\u003e\n pickle.dump(fig, file('ZH_ax.pkl', 'w+'))\n File \"/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n```\n\nIf I exclude the label formatter function in the `colorbar`, I get an error of\n\n```\nTraceback (most recent call last):\n File \"make_plots_new.py\", line 124, in \u003cmodule\u003e\n pickle.dump(fig, file('ZH_ax.pkl', 'w+'))\ncPickle.UnpickleableError: Cannot pickle \u003ctype 'Image'\u003e objects\n```\n\nHow can one pickle?\n","author":{"url":"https://github.com/kratsg","@type":"Person","name":"kratsg"},"datePublished":"2014-08-21T14:34:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/3392/matplotlib/issues/3392"}
| 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:29920b5f-ff6c-eb60-0187-6ba28678aa9f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D23E:153FD3:22B41F5:2F3D54E:6A539445 |
| html-safe-nonce | 9cf7f2ab26ce81439d026cc42e41a09504ea602f5a733f9a11fad06eff6cd932 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjNFOjE1M0ZEMzoyMkI0MUY1OjJGM0Q1NEU6NkE1Mzk0NDUiLCJ2aXNpdG9yX2lkIjoiNTI3ODkwMzAyNjM2Njc4MDQ4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 98fa3c2ab14006f9b0d738d191578a941a387fca980527ad219dd3cca4027d6f |
| hovercard-subject-tag | issue:40810385 |
| 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/3392/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5583fc68409464e0e1a88bd5205aa29d112e85db4912b690043a1e80931be5ee/matplotlib/matplotlib/issues/3392 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5583fc68409464e0e1a88bd5205aa29d112e85db4912b690043a1e80931be5ee/matplotlib/matplotlib/issues/3392 |
| og:image:alt | Couple of issues I've found. def latex_float(f, pos=0): float_str = "{0:.2g}".format(f) if "e" in float_str: base, exponent = float_str.split("e") return r"${0} \times 10^{{{1}}}$".format(base, int... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kratsg |
| 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