Skip to content

Commit

Permalink
feat: add plothist style (#528)
Browse files Browse the repository at this point in the history
* feat: add plothist style

* chore: bump mplhep_data

* chore: remove restyled

* chore: file org

* fix: redundancy
  • Loading branch information
andrzejnovak authored Oct 18, 2024
1 parent 19f9523 commit 6f4b23f
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .restyled.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ classifiers = [
]
dependencies = [
"matplotlib>=3.4",
"mplhep-data",
"mplhep-data>=0.0.4",
"numpy>=1.16.0",
"packaging",
"uhi>=0.2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/mplhep/styles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .atlas import ATLAS, ATLASAlt, ATLASTex
from .cms import CMS, ROOT, CMSTex, ROOTTex
from .lhcb import LHCb, LHCb1, LHCb2, LHCbTex, LHCbTex1, LHCbTex2
from .plothist import PLOTHIST

__all__ = (
"ALICE",
Expand All @@ -27,6 +28,7 @@
"LHCbTex",
"LHCbTex1",
"LHCbTex2",
"PLOTHIST",
"set_style",
"use",
"fira",
Expand Down
60 changes: 60 additions & 0 deletions src/mplhep/styles/plothist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from cycler import cycler

PLOTHIST = {
# General Settings
"figure.figsize": (6, 4),
"figure.facecolor": "white",
# "text.color" : .1,
# Fonts
"font.size": 15,
"xtick.labelsize": 15,
"ytick.labelsize": 15,
"axes.labelsize": 18,
"legend.fontsize": 12,
# "axes.labelcolor" : .1,
"text.usetex": False,
"font.family": ["serif", "sans-serif"],
"font.serif": ["Latin Modern Math", "Latin Modern Roman"],
"font.sans-serif": ["Latin Modern Sans"],
# Text in math mode
"mathtext.fontset": "cm",
"mathtext.default": "regular",
"legend.frameon": False,
"legend.framealpha": 0.5,
# Ticks
"xtick.direction": "in",
"ytick.direction": "in",
# "xtick.color" : .1,
# "ytick.color" : .1,
"xtick.minor.visible": True,
"ytick.minor.visible": True,
"ytick.left": True,
"ytick.right": False,
"xtick.top": False,
"xtick.bottom": True,
"xtick.major.size": 6,
"ytick.major.size": 6,
"xtick.minor.size": 3,
"ytick.minor.size": 3,
"xtick.major.pad": 8.0,
"ytick.major.pad": 5.0,
"axes.axisbelow": False,
"image.cmap": "viridis",
"grid.linestyle": "-",
"lines.solid_capstyle": "round",
"axes.grid": False,
"axes.facecolor": "white",
# "axes.edgecolor" : .0,
"axes.linewidth": 1,
"axes.formatter.limits": (-4, 4),
"axes.prop_cycle": cycler(
"color",
["#348ABD", "#E24A33", "#988ED5", "#777777", "#FBC15E", "#8EBA42", "#FFB5B8"],
),
"axes.formatter.use_mathtext": True,
"axes.formatter.useoffset": False,
"axes.labelpad": 6,
# "grid.color" : .8,
"errorbar.capsize": 0,
# "svg.hashsalt" : 8311311
}
Binary file added tests/baseline/test_style_plothist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/test_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ def test_style_lhcb2():
return fig


@pytest.mark.skipif(sys.platform != "linux", reason="Linux only")
@pytest.mark.mpl_image_compare(style="default", remove_text=False)
def test_style_plothist():
plt.rcParams.update(plt.rcParamsDefault)
plt.style.use(hep.style.PLOTHIST)
fig, ax = plt.subplots()
return fig


@pytest.mark.skipif(sys.platform != "linux", reason="Linux only")
@check_figures_equal(extensions=["pdf"])
@pytest.mark.parametrize(
Expand Down

0 comments on commit 6f4b23f

Please sign in to comment.