Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/matplotlib/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# how many histograms to draw in multi-hist plots
N_HISTS = 8 # exhibits all the colors in the Okabe-Ito cycler

dunestyle.OffWhiteBackground()

### 1D histogram example ###
def Hist1D(pdf):
x = np.random.normal(0, 1, 1000)
Expand Down Expand Up @@ -103,7 +105,7 @@ def DataMC(pdf):
transform=axs[0].transAxes)

fontdict = {"size": 14}
axs[0].text(0.68, 0.52, 'A = {0:0.2f}$\pm${1:0.2f}'.format(A, dA),
axs[0].text(0.68, 0.52, r'A = {0:0.2f}$\pm${1:0.2f}'.format(A, dA),
fontdict=fontdict,
transform=axs[0].transAxes)
axs[0].text(0.68, 0.46, r'$\mu$ = {0:0.2f}$\pm${1:0.2f}'.format(x0, dx0),
Expand All @@ -112,7 +114,7 @@ def DataMC(pdf):
axs[0].text(0.68, 0.40, r'$\sigma$ = {0:0.2f}$\pm${1:0.2f}'.format(sig, dsig),
fontdict=fontdict,
transform=axs[0].transAxes)
axs[0].text(0.68, 0.34, '$\chi^2$/ndof = {0:0.2f}/{1:d}'.format(chi2, ndf),
axs[0].text(0.68, 0.34, r'$\chi^2$/ndof = {0:0.2f}/{1:d}'.format(chi2, ndf),
fontdict=fontdict,
transform=axs[0].transAxes)
axs[0].legend(fontsize="xx-large") # since the upper panel is only 70% of the whole canvas, the legend is (by default) too small
Expand Down
1 change: 1 addition & 0 deletions examples/root/cpp/example.C
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ void OverlayExample(TCanvas * c, std::vector<TH1D>& hists)
//-------------------------------------------------------------------
void example()
{
dunestyle::OffWhiteBackground();

TCanvas c;

Expand Down
2 changes: 2 additions & 0 deletions examples/root/python/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def OverlayExample(c, hists):
#-------------------------------------------------------------------
#-------------------------------------------------------------------
if __name__ == "__main__":
dunestyle.OffWhiteBackground()

c = ROOT.TCanvas()
OneDHistExample(c)
c.SaveAs("example.pyroot.pdf(")
Expand Down
11 changes: 10 additions & 1 deletion guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,18 @@ All plots **must**:
- Check journal style guidelines carefully.
- Ensure plot text size is similar to that in the body of the article as possible.

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

#### Plot backgrounds:

The high contrast resulting from fully saturated colors against a white background can be difficult for individuals with dyslexia.
Consider using an "off-white" background instead.
The functions `OffWhiteBackground()` in both ROOT and matplotlib toolkits in this package will set figure backgrounds
to match the off-white background in the [official DUNE slide template](https://docs.dunescience.org/cgi-bin/ShowDocument?docid=78).

#### Markers/lines:

- When discrete curves are shown, the [Okabe-Ito color cycle](https://jfly.uni-koeln.de/color/) is recommended.
(`dune_plot_style` sets the default matplotlib cycler to Okabe-Ito;
the `dunestyle::colors::NextColor()` function can be used to obtain this cycle in ROOT.)
Expand Down
2 changes: 1 addition & 1 deletion src/matplotlib/python/dunestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def SetOkabeItoColors():
cyc = cycler(color=['#000000', '#D55E00', '#56B4E9', '#E69F00', '#009E73', '#CC79A7', '#0072B2', '#F0E442',])
plt.rc("axes", prop_cycle=cyc)

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

plt.rcParams['axes.facecolor'] = '#f0f0f0'
Expand Down
2 changes: 1 addition & 1 deletion src/matplotlib/stylelib/dune.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ text.hinting_factor : 8

#mathtext.fontset : cm

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

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