[plotstyle] bendalab colors
This commit is contained in:
parent
c029c56325
commit
680e2699bd
110
plotstyle.py
110
plotstyle.py
@ -11,6 +11,60 @@ figure_height = 6.0 # cm, for a 1 x 2 figure
|
|||||||
# points per inch:
|
# points per inch:
|
||||||
ppi = 72.0
|
ppi = 72.0
|
||||||
|
|
||||||
|
# colors:
|
||||||
|
|
||||||
|
def lighter(color, lightness):
|
||||||
|
""" Make a color lighter.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
color: string
|
||||||
|
An RGB color as a hexadecimal string (e.g. '#rrggbb').
|
||||||
|
lightness: float
|
||||||
|
The smaller the lightness, the lighter the returned color.
|
||||||
|
A lightness of 1 leaves the color untouched.
|
||||||
|
A lightness of 0 returns white.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
color: string
|
||||||
|
The lighter color as a hexadecimal RGB string (e.g. '#rrggbb').
|
||||||
|
"""
|
||||||
|
r = int(color[1:3], 16)
|
||||||
|
g = int(color[3:5], 16)
|
||||||
|
b = int(color[5:7], 16)
|
||||||
|
rl = r + (1.0-lightness)*(0xff - r)
|
||||||
|
gl = g + (1.0-lightness)*(0xff - g)
|
||||||
|
bl = b + (1.0-lightness)*(0xff - b)
|
||||||
|
return '#%02X%02X%02X' % (rl, gl, bl)
|
||||||
|
|
||||||
|
|
||||||
|
def darker(color, saturation):
|
||||||
|
""" Make a color darker.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
color: string
|
||||||
|
An RGB color as a hexadecimal string (e.g. '#rrggbb').
|
||||||
|
saturation: float
|
||||||
|
The smaller the saturation, the darker the returned color.
|
||||||
|
A saturation of 1 leaves the color untouched.
|
||||||
|
A saturation of 0 returns black.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
color: string
|
||||||
|
The darker color as a hexadecimal RGB string (e.g. '#rrggbb').
|
||||||
|
"""
|
||||||
|
r = int(color[1:3], 16)
|
||||||
|
g = int(color[3:5], 16)
|
||||||
|
b = int(color[5:7], 16)
|
||||||
|
rd = r * saturation
|
||||||
|
gd = g * saturation
|
||||||
|
bd = b * saturation
|
||||||
|
return '#%02X%02X%02X' % (rd, gd, bd)
|
||||||
|
|
||||||
|
|
||||||
# colors:
|
# colors:
|
||||||
colors = {
|
colors = {
|
||||||
'red': '#CC0000',
|
'red': '#CC0000',
|
||||||
@ -21,6 +75,56 @@ colors = {
|
|||||||
'blue': '#0000CC'
|
'blue': '#0000CC'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
""" Muted colors used by the Benda-lab. """
|
||||||
|
colors_bendalab = {}
|
||||||
|
colors_bendalab['red'] = '#C02010'
|
||||||
|
colors_bendalab['orange'] = '#F78010'
|
||||||
|
colors_bendalab['yellow'] = '#F7E030'
|
||||||
|
colors_bendalab['green'] = '#97C010'
|
||||||
|
colors_bendalab['cyan'] = '#40A787'
|
||||||
|
colors_bendalab['blue'] = '#2050A0'
|
||||||
|
colors_bendalab['purple'] = '#7040A0'
|
||||||
|
colors_bendalab['pink'] = '#D72060'
|
||||||
|
|
||||||
|
""" Vivid colors used by the Benda-lab. """
|
||||||
|
colors_bendalab_vivid = {}
|
||||||
|
colors_bendalab_vivid['red'] = '#D01000'
|
||||||
|
colors_bendalab_vivid['orange'] = '#FF9000'
|
||||||
|
colors_bendalab_vivid['yellow'] = '#FFF700'
|
||||||
|
colors_bendalab_vivid['green'] = '#30D700'
|
||||||
|
colors_bendalab_vivid['cyan'] = '#00F0B0'
|
||||||
|
colors_bendalab_vivid['blue'] = '#0020C0'
|
||||||
|
colors_bendalab_vivid['purple'] = '#B000B0'
|
||||||
|
colors_bendalab_vivid['pink'] = '#F00080'
|
||||||
|
|
||||||
|
# colors for the plots of the script:
|
||||||
|
colors = colors_bendalab_vivid
|
||||||
|
colors['lightorange'] = colors['yellow']
|
||||||
|
#colors['yellow'] = lighter(colors['yellow'], 0.65)
|
||||||
|
colors['yellow'] = '#FFFF55'
|
||||||
|
|
||||||
|
# line styles:
|
||||||
|
# 'B1': prominent line with first color and style from color group 'B'
|
||||||
|
# 'C2m': minor line with second color and style from color group 'C'
|
||||||
|
ls = {
|
||||||
|
'A1': {'c': colors['red'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'A2': {'c': colors['orange'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'A3': {'c': colors['lightorange'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'B1': {'c': colors['orange'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'B2': {'c': colors['lightorange'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'B3': {'c': colors['yellow'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'C1': {'c': colors['green'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'D1': {'c': colors['blue'], 'linestyle': '-', 'linewidth': 3},
|
||||||
|
'A1m': {'c': colors['red'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'A2m': {'c': colors['orange'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'A3m': {'c': colors['lightorange'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'B1m': {'c': colors['orange'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'B2m': {'c': colors['lightorange'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'B3m': {'c': colors['yellow'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'C1m': {'c': colors['green'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
'D1m': {'c': colors['blue'], 'linestyle': '-', 'linewidth': 2},
|
||||||
|
}
|
||||||
|
|
||||||
# factor for scaling widths of bars in a bar plot:
|
# factor for scaling widths of bars in a bar plot:
|
||||||
bar_fac = 1.0
|
bar_fac = 1.0
|
||||||
|
|
||||||
@ -43,11 +147,11 @@ def cm_size(*args):
|
|||||||
inches: float or list of floats
|
inches: float or list of floats
|
||||||
Input arguments converted to inch.
|
Input arguments converted to inch.
|
||||||
"""
|
"""
|
||||||
inch_per_cm = 2.54
|
cm_per_inch = 2.54
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
return args[0]/inch_per_cm
|
return args[0]/cm_per_inch
|
||||||
else:
|
else:
|
||||||
return [v/inch_per_cm for v in args]
|
return [v/cm_per_inch for v in args]
|
||||||
|
|
||||||
|
|
||||||
def adjust_fs(fig=None, left=5.5, right=0.5, bottom=2.8, top=0.5):
|
def adjust_fs(fig=None, left=5.5, right=0.5, bottom=2.8, top=0.5):
|
||||||
|
@ -23,7 +23,7 @@ if __name__ == "__main__":
|
|||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
spec = gridspec.GridSpec(nrows=1, ncols=2, **adjust_fs(fig, left=4.5))
|
spec = gridspec.GridSpec(nrows=1, ncols=2, **adjust_fs(fig, left=4.5))
|
||||||
ax1 = fig.add_subplot(spec[0, 0])
|
ax1 = fig.add_subplot(spec[0, 0])
|
||||||
ax1.plot(xx, yy, colors['red'], lw=2)
|
ax1.plot(xx, yy, **ls['A1'])
|
||||||
ax1.scatter(x, y, c=colors['blue'], edgecolor='white', s=50)
|
ax1.scatter(x, y, c=colors['blue'], edgecolor='white', s=50)
|
||||||
ax1.set_xlabel('Hair deflection', 'nm')
|
ax1.set_xlabel('Hair deflection', 'nm')
|
||||||
ax1.set_ylabel('Conductance', 'nS')
|
ax1.set_ylabel('Conductance', 'nS')
|
||||||
@ -35,7 +35,7 @@ if __name__ == "__main__":
|
|||||||
ax2 = fig.add_subplot(spec[0, 1])
|
ax2 = fig.add_subplot(spec[0, 1])
|
||||||
xg = np.linspace(-3.0, 3.01, 200)
|
xg = np.linspace(-3.0, 3.01, 200)
|
||||||
yg = st.norm.pdf(xg, 0.0, sigma)
|
yg = st.norm.pdf(xg, 0.0, sigma)
|
||||||
ax2.plot(xg, yg, colors['red'], lw=2)
|
ax2.plot(xg, yg, **ls['A1'])
|
||||||
bw = 0.25
|
bw = 0.25
|
||||||
h, b = np.histogram(y-boltzmann(x, x0, k), np.arange(-3.0, 3.01, bw))
|
h, b = np.histogram(y-boltzmann(x, x0, k), np.arange(-3.0, 3.01, bw))
|
||||||
ax2.bar(b[:-1], h/np.sum(h)/(b[1]-b[0]), fc=colors['yellow'], width=bar_fac*bw, align='edge')
|
ax2.bar(b[:-1], h/np.sum(h)/(b[1]-b[0]), fc=colors['yellow'], width=bar_fac*bw, align='edge')
|
||||||
|
Reference in New Issue
Block a user