Skip to content

Commit 418d6f1

Browse files
authored
Merge pull request #55 from DUNE/feature/off-white-doc
Add documentation about off-white background + enforce in examples
2 parents 1231279 + 34d4e4f commit 418d6f1

6 files changed

Lines changed: 19 additions & 5 deletions

File tree

examples/matplotlib/example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
# how many histograms to draw in multi-hist plots
2323
N_HISTS = 8 # exhibits all the colors in the Okabe-Ito cycler
2424

25+
dunestyle.OffWhiteBackground()
26+
2527
### 1D histogram example ###
2628
def Hist1D(pdf):
2729
x = np.random.normal(0, 1, 1000)
@@ -103,7 +105,7 @@ def DataMC(pdf):
103105
transform=axs[0].transAxes)
104106

105107
fontdict = {"size": 14}
106-
axs[0].text(0.68, 0.52, 'A = {0:0.2f}$\pm${1:0.2f}'.format(A, dA),
108+
axs[0].text(0.68, 0.52, r'A = {0:0.2f}$\pm${1:0.2f}'.format(A, dA),
107109
fontdict=fontdict,
108110
transform=axs[0].transAxes)
109111
axs[0].text(0.68, 0.46, r'$\mu$ = {0:0.2f}$\pm${1:0.2f}'.format(x0, dx0),
@@ -112,7 +114,7 @@ def DataMC(pdf):
112114
axs[0].text(0.68, 0.40, r'$\sigma$ = {0:0.2f}$\pm${1:0.2f}'.format(sig, dsig),
113115
fontdict=fontdict,
114116
transform=axs[0].transAxes)
115-
axs[0].text(0.68, 0.34, '$\chi^2$/ndof = {0:0.2f}/{1:d}'.format(chi2, ndf),
117+
axs[0].text(0.68, 0.34, r'$\chi^2$/ndof = {0:0.2f}/{1:d}'.format(chi2, ndf),
116118
fontdict=fontdict,
117119
transform=axs[0].transAxes)
118120
axs[0].legend(fontsize="xx-large") # since the upper panel is only 70% of the whole canvas, the legend is (by default) too small

examples/root/cpp/example.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void OverlayExample(TCanvas * c, std::vector<TH1D>& hists)
225225
//-------------------------------------------------------------------
226226
void example()
227227
{
228+
dunestyle::OffWhiteBackground();
228229

229230
TCanvas c;
230231

examples/root/python/example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def OverlayExample(c, hists):
204204
#-------------------------------------------------------------------
205205
#-------------------------------------------------------------------
206206
if __name__ == "__main__":
207+
dunestyle.OffWhiteBackground()
208+
207209
c = ROOT.TCanvas()
208210
OneDHistExample(c)
209211
c.SaveAs("example.pyroot.pdf(")

guidelines.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,18 @@ All plots **must**:
7979
- Check journal style guidelines carefully.
8080
- Ensure plot text size is similar to that in the body of the article as possible.
8181

82-
### Colo(u)r palette:
82+
### Colo(u)r considerations:
8383
Color choices should look appealing and be accessible to those with color-vision deficiency (CVD).
8484

85+
#### Plot backgrounds:
86+
87+
The high contrast resulting from fully saturated colors against a white background can be difficult for individuals with dyslexia.
88+
Consider using an "off-white" background instead.
89+
The functions `OffWhiteBackground()` in both ROOT and matplotlib toolkits in this package will set figure backgrounds
90+
to match the off-white background in the [official DUNE slide template](https://docs.dunescience.org/cgi-bin/ShowDocument?docid=78).
91+
92+
#### Markers/lines:
93+
8594
- When discrete curves are shown, the [Okabe-Ito color cycle](https://jfly.uni-koeln.de/color/) is recommended.
8695
(`dune_plot_style` sets the default matplotlib cycler to Okabe-Ito;
8796
the `dunestyle::colors::NextColor()` function can be used to obtain this cycle in ROOT.)

src/matplotlib/python/dunestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def SetOkabeItoColors():
147147
cyc = cycler(color=['#000000', '#D55E00', '#56B4E9', '#E69F00', '#009E73', '#CC79A7', '#0072B2', '#F0E442',])
148148
plt.rc("axes", prop_cycle=cyc)
149149

150-
def off_white_bkg():
150+
def OffWhiteBackground():
151151
""" Set the background color of the figure to match the off-white background of the updated DUNE slide template. """
152152

153153
plt.rcParams['axes.facecolor'] = '#f0f0f0'

src/matplotlib/stylelib/dune.mplstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ text.hinting_factor : 8
1313

1414
#mathtext.fontset : cm
1515

16-
figure.facecolor: white (default, can be changed with off_white_bkg to #f0f0f0 for slides)
16+
figure.facecolor: white # (default, can be changed with off_white_bkg to #f0f0f0 for slides)
1717

1818
axes.facecolor: white # eeeeee (default, can be changed with off_white_bkg to #f0f0f0 for slides)
1919
axes.edgecolor: black

0 commit comments

Comments
 (0)