Comments (9)
cc @kratsg as he might have thoughts here too.
from mplhep.
Yup. @matthewfeickert what mpl version are you on. matplotlib/matplotlib#16509 might have changed the behaviour because I can't replicate it on master and it should be available in 3.3
.
Otherwise, you should try setting axes.unicode_minus=False
to replace the minus glyph by a hyphen, which is in most fonts.
from mplhep.
what mpl version are you on. matplotlib/matplotlib#16509 might have changed the behaviour because I can't replicate it on master and it should be available in
3.3
.
Hm, that's strange as I'm on
$ pip list | grep matplotlib
matplotlib 3.3.1
and still seeing this (I'm on Ubuntu FWIW). Though thanks for contributing upstream to matplotlib
! That's so great to see in general. :)
Otherwise, you should try setting
axes.unicode_minus=False
to replace the minus glyph by a hyphen, which is in most fonts.
Hm. This doesn't seem to help things. In the original script if I append that immediately after the ATLAS style
plt.style.use(mplhep.style.ATLAS)
matplotlib.rcParams["axes.unicode_minus"] = False
I still get the same result.
However, I understand why you're having trouble repliating as this is the result of the fonts on my system. We can see this by looking at the following Dockerfile:
FROM python:3.8
RUN python -m pip install --upgrade pip setuptools wheel && \
python -m pip install --no-cache-dir numpy mplhep && \
python -c "import matplotlib"
ENTRYPOINT ["/bin/bash"]
which can be built with
docker build . -f Dockerfile -t mplhepissue-178:latest
and then with the script (named issue_178.py
) in the same working directory run
$ docker run --rm -v $PWD:$PWD -w $PWD mplhepissue-178:latest -c "python issue_178.py"
resulting in
findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans.
findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans.
findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans.
findfont: Font family ['cursive'] not found. Falling back to DejaVu Sans.
'texgyreheros-regular.otf' can not be subsetted into a Type 3 font. The entire font will be embedded in the output.
So apparently the fonts exist on the version of Debian
$ docker run --rm mplhepissue-178:latest -c "cat /etc/os-release"
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
but not on Ubuntu 19.10. So I'll try to figure out what fonts are missing and then post a fix here so that we can close this Issue and other Ubuntu users lagging behind the 20.04 LTS release can get help.
from mplhep.
Hmm, thanks for the thorough report! One naive way to check which font is causing trouble would be to cycle through the font list you pass in one at a time.
On a side note, can you check what happens if you also append Tex Gyre Heros which ships with mplhep and should have a reasonable char set.
I have suggested appending this to the list in the past, but @kratsg has a preference for not having Helvetica failing loudly.
from mplhep.
I have suggested appending this to the list in the past, but @kratsg has a preference for not having Helvetica failing loudly.
Not sure what you mean by this. But we should really adhere to the ATLAS styleguide. Nobody's going to know that the font is different so obviously unless they're a font designer, but I don't think it's right to force a font that is not recommended by the official pubcom.
from mplhep.
@matthewfeickert are you planning to come back to this or can I close it?
from mplhep.
@matthewfeickert are you planning to come back to this or can I close it?
I am planning on coming back to it, but this can be closed for now as it isn't a mplhep
bug.
from mplhep.
For the record, the fix was incredibly easy and just total oversight on my part. I had forgotten that matplotlib
has a font cache and matplotlib.font_manager
. So all that is needed is
import matplotlib.font_manager
matplotlib.font_manager._rebuild()
as I apparently had the correct fonts (I think all that is needed is the dejavu
font).
from mplhep.
Actually, the fix ended up being more subtle than just the font list cache. For the Stack Ovreflow question "matplotlib mathtext font warning: Font 'default' does not have a glyph" I had more than just fontlist-v330.json
in the matplotlib
cache
$ ls -htra ~/.cache/matplotlib/
.. tex.cache fontlist-v330.json .
so rebuilding the font list cache with
import matplotlib.font_manager
matplotlib.font_manager._rebuild()
or
rm ~/.cache/matplotlib/fontlist-v330.json
wasn't sufficient. Instead the entire matplotlib
cache needs to be updated, which is most easily done with
rm ~/.cache/matplotlib/*
from mplhep.
Related Issues (20)
- [Security] Workflow publish-package.yml is using vulnerable action actions/checkout
- Suppress `yerr` drawing globally HOT 3
- mplhep styles with contourf log scale causes hang HOT 8
- Chaning colors of bars created by histplot makes bar position change HOT 2
- Add HEAD of dependencies GHA workflow HOT 1
- Upload of pytest_results artifact 'fails with no files were found' HOT 3
- `density=True` does not account for bin edges
- bug: mplhep logo placement is slow.. HOT 1
- histplot() with histtype="errorbar" crashes when data contains inf or nan HOT 3
- ENH: Add a `density` option for hist2dplot?
- mplhep LHCb2 style conflicts with subplots_adjust(hspace=0) HOT 1
- ENH: Gallery HOT 2
- CI failing HOT 1
- Add CITATION.cff
- Custom text location HOT 3
- Use gh-action-pypi-publish v1.7.0+ APIs
- Matplotlib warnings
- Histplot errorbars HOT 3
- [Bug] histplot raises IndexError when plotting an histogram with one bin HOT 2
- Update return type of exp label/text
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mplhep.