-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
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
Cannot export to html when matplotlib axis is negative. #127
Comments
Thanks for reporting this. I've tried to reproduce on my machine but I was able to run the following code successfully: import matplotlib.pyplot as plt
import esparto
def test_no_negative_char():
fig, ax = plt.subplots()
x = [1,2,3,4,5]
y = [1,0.5, 0, 1, 2]
ax.plot(x, y)
page = esparto.Page(title="Test")
page["Plot"] = fig
page.save_html("test-fig-01.html")
def test_negative_char():
"""This fails
UnicodeEncodeError: 'charmap' codec can't encode character '\u2212' in position 13531: character maps to <undefined>
"""
fig, ax = plt.subplots()
x = [1,2,3,4,5]
y = [-1,-0.5, 0, 1, 2]
ax.plot(x, y)
page = esparto.Page(title="Test")
page["Plot"] = fig
page.save_html("test-fig-02.html")
if __name__ == "__main__":
test_no_negative_char()
test_negative_char() This makes me think it's a Windows OS specific issue as I've been developing and testing in a Linux environment. Could you share the full error message so I can pinpoint where the error is occurring? |
One other thing, could you try setting the figure format to PNG as an interim solution? from esparto import options
options.matplotlib.notebook_format = "png"
options.matplotlib.html_output_format = "png" |
Hi domvwt I have a fix that works on my machine. In esparto/publish/output.py, line 69
Specifying the encoding fixes this for me:
This is the full error message I was getting:
|
Although a funny side effect of the above fix is that the page icon is now random letters:
|
What if we replace the text with this This is on line 7 of https://github.com/domvwt/esparto/blob/main/esparto/resources/jinja/base.html.jinja. |
Yes that works :) |
Great, thanks for making the fix! If you can make a pull request with your changes I'll merge and make a new release. |
I've made a |
Description
Cannot export to html when matplotlib axis is negative. I get the error:
UnicodeEncodeError: 'charmap' codec can't encode character '\u2212' in position 13531 character maps to
What I Did
The text was updated successfully, but these errors were encountered: