matplotlib / matplotlib/matplotlib
Support partial usetex in ps output
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
I am trying to save some figures I made as .ps or .eps but I am getting an error. I narrowed the error down to the fact that I am using Latex for some of the text in my figure but using `rc.params['text.usetex'] = False`. Here is some code that reproduces the bug:
```python
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
plt.text(0.5, 0.5, 'Here is some text, $math mode$', ha='center', va='center', usetex=True)
fig.savefig('test.ps')
```
The error you get is `AttributeError: 'RendererPS' object has no attribute 'textcnt'`
When looking at [this code in in the RendererPS class](https://github.com/matplotlib/matplotlib/blob/ab98852fa3b760e87208de53d058f82c3bf934bc/lib/matplotlib/backends/backend_ps.py#L191) the `textcnt` attribute is only added when `rc.params['text.usetex'] = True`. However I am just using Latex for specific text objects with the option `usetex=True`. Is there a way to save these figures as .ps or .eps?
I am using Matplotlib 1.5.1 installed via conda on Windows with python 2.7. I also tested it with Matplotlib 2.0.0b4 which also produced the same error, however I would prefer a solution for 1.5.1 if possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/matplotlib/backends/backend_ps.py and the RendererPS handling of textcnt, then run the issue's minimal Python example that saves a figure as test.ps. Confirm the behavior for text objects using usetex=True while the global setting is false; done means PS and EPS output save without the reported AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex, matplotlib, python
- Domain
- backend, data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100