Skip to content

evince misrenders some pdf bar plots #12864

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

Closed
laborleben opened this issue Nov 22, 2018 · 7 comments
Closed

evince misrenders some pdf bar plots #12864

laborleben opened this issue Nov 22, 2018 · 7 comments

Comments

@laborleben
Copy link

This is a regression in matplotlib 2.x.x. The bug does not exist in matplotlib 1.5.x.

Bug report

Bug summary

When using some special numbers matplotlib.bar() is missing y-ticks and corresponding y-tick labels.

Code for reproduction

arr = np.array([3765, 3792], dtype=np.int32)
plt.bar([0, 1], arr)
plt.yscale('log')

Actual outcome

bildschirmfoto 2018-11-22 um 15 45 51

Expected outcome

bildschirmfoto 2018-11-22 um 16 03 02

Matplotlib version

  • Operating system: macOS/Ubuntu
  • Matplotlib version: 2.2.3 (conda install matplotlib)
  • Matplotlib backend: MacOSX/Qt5Agg
  • Python version: Anaconda 2.7

Bonus

Plotting issues with Evince 3.18.2 in Ubuntu 16.04. The bars are upside down depending on the zoom level.

Zoom level: 140%
screenshot_2018-11-22_16-11-16

Zoom level: 170%
screenshot_2018-11-22_16-11-41

@anntzer
Copy link
Contributor

anntzer commented Nov 22, 2018

The ticking issue is already open as #8768 (especially #8768 (comment)), but the pdf/evince issue is new. I can't repro using okular (also using poppler as rendering backend) or mupdf or zathura(mupdf) or acroread, so I think it's a bug in evince, but heh.
(Also pdfs generated by mplcairo do not appear to expose this issue.)

@laborleben
Copy link
Author

Yes, that's true, I couldn't reproduce the PDF displaying issue anywhere else beside Evince.

@laborleben
Copy link
Author

Thanks for linking #8768. I was wondering no else found this bug before me :-)

@anntzer anntzer changed the title REG: bar() is missing y-ticks and tick labels when using special numbers evince misrenders some pdf bar plots Nov 22, 2018
@anntzer
Copy link
Contributor

anntzer commented Nov 22, 2018

Relabeled the issue to focus on the evince problem as the ticker problem is already tracked elsewhere.
Can you report on Evince's bug tracker as well and see whether anything comes out of that?

@laborleben
Copy link
Author

laborleben commented Nov 23, 2018

Maybe for very small ranges change locator:

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np

arr = np.array([3765, 3792], dtype=np.float32)
plt.clf()
plt.bar(range(len(arr)), arr)
plt.yscale('log')
base_exponents = np.unique(np.floor(np.log10(plt.ylim())))
msb_digits = np.floor(plt.ylim() / (10**np.floor(np.log10(plt.ylim())))).astype(np.int)
if (base_exponents.size == 1 or np.abs(np.diff(base_exponents))[0] < 1) and np.count_nonzero(np.bincount(msb_digits)) < 3:
    ax = plt.gca()
    ax.yaxis.set_major_locator(locator=ticker.NullLocator())
    ax.yaxis.set_minor_locator(locator=ticker.AutoLocator())

This at least puts some numbers on the y-axis. But this doesn't solve the Evince issue.
The output PDF is now missing a part on the left side.

bildschirmfoto 2018-11-23 um 12 10 37

@laborleben
Copy link
Author

plt.tight_layout()

or

plt.savefig("test.pdf", bbox_inches="tight")

fixes the displaying of the tick labels.

@anntzer
Copy link
Contributor

anntzer commented Jan 7, 2019

Closing as I think the remaining issue belongs to evince (https://gitlab.gnome.org/GNOME/evince/issues/1056) and I don't think there's anything else to do on Matplotlib's side.

@anntzer anntzer closed this as completed Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants