Title: Feature request: set mathtext fonts via the object oriented API · Issue #6518 · matplotlib/matplotlib · GitHub
Open Graph Title: Feature request: set mathtext fonts via the object oriented API · Issue #6518 · matplotlib/matplotlib
X Title: Feature request: set mathtext fonts via the object oriented API · Issue #6518 · matplotlib/matplotlib
Description: As far as I can see (and according to the documentation), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam. It would be nice if there were some way to control the fonts used for mathtext rend...
Open Graph Description: As far as I can see (and according to the documentation), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam. It would be nice if there were some way to ...
X Description: As far as I can see (and according to the documentation), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam. It would be nice if there were some way to ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/6518
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request: set mathtext fonts via the object oriented API","articleBody":"As far as I can see (and according to [the documentation](http://matplotlib.org/users/mathtext.html)), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam.\n\nIt would be nice if there were some way to control the fonts used for mathtext rendering without messing with the rcparams system. Maybe the font could be chosen based on the `FontProperties` instance associated with the Text object? To make a concrete example, it would be nice if the y label for this plot were rendered using a serif font, like the rest of the plot.\n\n``` python\n\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom matplotlib.font_manager import FontProperties\n\nfig, ax = plt.subplots()\n\nfp = FontProperties(**{'family': 'stixgeneral'})\n\nim = ax.imshow(np.random.random((800, 800)))\ncb = fig.colorbar(im)\ncbax = cb.ax\n\nax.set_xlabel('x label')\nax.set_ylabel(r'$\\rm{y\\ label}$')\ncb.set_label('colorbar label')\n\nlabels = ax.xaxis.get_ticklabels() + ax.yaxis.get_ticklabels()\nlabels += cbax.yaxis.get_ticklabels()\nlabels += [ax.xaxis.label, ax.yaxis.label, cbax.yaxis.label]\n\nfor label in labels:\n label.set_fontproperties(fp)\n\nplt.savefig('test.png')\n\n```\n\nFor additional context, see #6514 and my message to the matplotlib-devel mailing list: https://mail.python.org/pipermail/matplotlib-devel/2016-May/000454.html\n","author":{"url":"https://github.com/ngoldbaum","@type":"Person","name":"ngoldbaum"},"datePublished":"2016-06-01T02:39:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/6518/matplotlib/issues/6518"}
| 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:c3a53c09-d348-10a3-3aed-38e25bc83599 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DEC6:39B58C:4C85A:613F8:6A52698D |
| html-safe-nonce | 2273259ab986c3854a8fee7027152c2c2f438fdf3ac3e96cb7f2daa93c8c57c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUM2OjM5QjU4Qzo0Qzg1QTo2MTNGODo2QTUyNjk4RCIsInZpc2l0b3JfaWQiOiI0NDAxOTA3NDQzNjczNzUzOTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9c58ee2b9429daf06711f57383a0718cfc70fca9f8bacaa3d5f561b0408ea7cc |
| hovercard-subject-tag | issue:157811592 |
| 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/6518/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d70db4f2bc4b5b1241dbb59276efb252faf20bb98d5e4148757a20813a73237/matplotlib/matplotlib/issues/6518 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d70db4f2bc4b5b1241dbb59276efb252faf20bb98d5e4148757a20813a73237/matplotlib/matplotlib/issues/6518 |
| og:image:alt | As far as I can see (and according to the documentation), the only way to set the font of mathtext snippets in plots is via the mathtext.fontset rcparam. It would be nice if there were some way to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ngoldbaum |
| 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