| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ``MathTextParser("bitmap")`` is deprecated | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The associated APIs ``MathtextBackendBitmap``, ``MathTextParser.to_mask``, | ||
| ``MathTextParser.to_rgba``, ``MathTextParser.to_png``, and | ||
| ``MathTextParser.get_depth`` are likewise deprecated. | ||
|
|
||
| To convert a text string to an image, either directly draw the text to an | ||
| empty `.Figure` and save the figure using a tight bbox, as demonstrated in | ||
| :doc:`/gallery/text_labels_and_annotations/mathtext_asarray`, or use | ||
| `.mathtext.math_to_image`. | ||
|
|
||
| When using `.math_to_image`, text color can be set with e.g.:: | ||
|
|
||
| with plt.rc_context({"text.color": "tab:blue"}): | ||
| mathtext.math_to_image(text, filename) | ||
|
|
||
| and an RGBA array can be obtained with e.g.:: | ||
|
|
||
| from io import BytesIO | ||
| buf = BytesIO() | ||
| mathtext.math_to_image(text, buf, format="png") | ||
| buf.seek(0) | ||
| rgba = plt.imread(buf) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -249,9 +249,9 @@ def get_label_width(self, lev, fmt, fsize): | |
| .get_text_width_height_descent(lev, fsize)) | ||
| elif ismath: | ||
| if not hasattr(self, '_mathtext_parser'): | ||
| self._mathtext_parser = mathtext.MathTextParser('bitmap') | ||
| img, _ = self._mathtext_parser.parse(lev, dpi=72, | ||
| prop=self.labelFontProps) | ||
| self._mathtext_parser = mathtext.MathTextParser('agg') | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitythis specific use is going away via #16171.
Sorry, something went wrong.
All reactions
|
||
| _, _, _, _, _, img, _ = self._mathtext_parser.parse( | ||
| lev, dpi=72, prop=self.labelFontProps) | ||
| _, lw = np.shape(img) # at dpi=72, the units are PostScript points | ||
| else: | ||
| # width is much less than "font size" | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy not use math_to_image here?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.