Założenia:
Wykresy oparte są o bibliotekę Matplotlib, a opracowany styl jest zawarty w pliku tekstowym PhD_grayscale.mplstyle dostępnym pod linkiem.
import locale
import matplotlib.pyplot as plt
import numpy as np
import itertools
locale._override_localeconv["thousands_sep"] = " "
locale._override_localeconv["decimal_point"]= ','
try:
# # if file is stored locally
# plt.style.use("F:\\Dyplomowe\\Doktorat\\PhD_grayscale.mplstyle")
# use style from internet location
plt.style.use("https://www.fuw.edu.pl/~abogucki/PhDbackups/style/PhD_grayscale.mplstyle")
except:
print("Can't find PhD_grayscale.mplstyle")
print("Avaliable styles:")
print([style for style in plt.style.available])
print("Now using 'default'")
plt.style.use(['default'])
#-------------------------------
# example data
xs = np.asarray([-2,2,3,6,7,8,9,10])
ys = np.asarray([8, 2,4,3,4,6,8,4])
#-------------------------------
hatches = itertools.cycle(['/////', '\\\\\\\\\\', '||||', '----', '++++', 'xxxx', 'oooo', 'OOOO'])
fig, ax = plt.subplots(figsize=(6,4), dpi=125)
for xi,yi in zip(xs,ys):
h = next(hatches)
ax.bar(xi,yi, hatch = h, fill='full',facecolor='white',edgecolor='black')
for i in range(8):
ax.plot(xs,ys+i+3)
long_test_text = 'D(E) 1234567890° α, β, Γ γ Δ δ ε ζ, η, Θ θ, Ι κ, Λ λ μ,\n ν, Ξ ξ Π π ρ, Σ σ/ς, τ, υ, Φ φ, Χ χ, Ψ ψ Ω ω'
polski = 'Zażółć gęślą jaźń \n ZAŻÓŁĆ GĘŚLĄ JAŹŃ'
ax.set_title(long_test_text)
ax.set_xlabel(long_test_text)
ax.set_ylabel('ważna zmienna (jedn. wzgl.)')
ax.text(-0.5,3,"monochromator \nGQJGC ν = ћω")
ax.text(3,15, polski)
fig.set_tight_layout(False)
plt.show()
#--------------------------------
# info about system
import matplotlib
print('Matplotlib version:', matplotlib.__version__)
# On Windows, both the config directory and the cache directory are the same
print('Matplotlib cache directory:', matplotlib.get_cachedir())
print('Matplotlib config directory:', matplotlib.get_configdir())
PhD_grayscale.mplstyle¶lines.linewidth: 1.5 # line width in points
lines.color: C0
lines.markersize : 6
lines.marker: o # the default marker
lines.markerfacecolor: white # the default marker face color
lines.markeredgewidth: 1.0
lines.scale_dashes: True
lines.antialiased: True
###################
font.family: sans-serif
font.sans-serif: Inter, Arial, DejaVu Sans, sans-serif
font.style: normal
font.variant: normal
font.weight: normal
font.stretch: normal
font.size: 10.0
###################
figure.figsize: 4.96, 6.7 # figure size in inches
figure.dpi: 150 # figure dots per inch
figure.constrained_layout.use: True # When True, automatically make plot
# elements fit on the figure. (Not
# compatible with `autolayout`, above).
###################
axes.facecolor: white # axes background color
axes.edgecolor: black # axes edge color
axes.linewidth: 1.0 # edge line width
axes.grid: False # display grid or not
axes.formatter.use_locale: True # When True, format tick labels
# according to the user's locale.
# For example, use ',' as a decimal
# separator in the fr_FR locale.
axes.unicode_minus: True # use Unicode for the minus symbol rather than hyphen. See
# https://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
# More refined control can be achieved by providing a dash tuple (offset, (on_off_seq)).
# For example, (0, (3, 10, 1, 15)) means (3pt line, 10pt space, 1pt line, 15pt space) with no offset.
axes.prop_cycle: (cycler('marker', ['o', '+', 'x', 'o', 'o', '+', 'x', 'o']) + cycler('markersize', [6, 6, 6, 3, 6, 6, 6, 3])+ cycler('markerfacecolor', ['w', 'w', 'w', 'w','k', 'k', 'k', 'k']) + cycler('color', ['k', 'k', 'k', 'k','k', 'k', 'k', 'k']) + cycler('ls', [(0, ()), (0, (4, 2)), (0, (1, 2)), (0, (1, 2, 6, 2)), (0, (1, 1, 6, 1,1,1)), (0, (1, 1, 6, 1,1,3)), (0, (1, 1, 12,1)),(0, (9, 1))]))
axes.autolimit_mode: data # If "data", use axes.xmargin and axes.ymargin as is.
# If "round_numbers", after application of margins, axis
# limits are further expanded to the nearest "round" number.
###################
xtick.top: True # draw ticks on the top side
xtick.bottom: True # draw ticks on the bottom side
xtick.minor.visible: False
xtick.labeltop: False # draw label on the top
xtick.labelbottom: True # draw label on the bottom
xtick.major.size: 5 # major tick size in points
xtick.minor.size: 2 # major tick size in points
xtick.major.width: 1 # major tick width in points
xtick.minor.width: 1 # minor tick width in points
xtick.labelsize: medium # font size of the tick labels
xtick.direction: in # direction: {in, out, inout}
ytick.left: True # draw ticks on the left side
ytick.right: True # draw ticks on the right side
ytick.minor.visible: False
ytick.labelleft: True # draw label on the left
ytick.labelright: False # draw label on the right
ytick.major.size: 5 # major tick size in points
ytick.minor.size: 2 # major tick size in points
ytick.major.width: 1 # major tick width in points
ytick.minor.width: 1 # minor tick width in points
ytick.labelsize: medium # font size of the tick labels
ytick.direction: in # direction: {in, out, inout}
###################