[statistics] simplified plots, last part, added pointstyles
This commit is contained in:
parent
999a3003a6
commit
75aa46d71c
54
plotstyle.py
54
plotstyle.py
@ -18,9 +18,10 @@ colors['orange'] = '#FF9900'
|
||||
colors['lightorange'] = '#FFCC00'
|
||||
colors['yellow'] = '#FFFF66'
|
||||
colors['green'] = '#99FF00'
|
||||
colors['blue'] = '#0000CC'
|
||||
colors['blue'] = '#0010CC'
|
||||
colors['gray'] = '#A7A7A7'
|
||||
colors['black'] = '#000000'
|
||||
colors['white'] = '#FFFFFF'
|
||||
|
||||
#colors_bendalab_vivid['red'] = '#D71000'
|
||||
#colors_bendalab_vivid['orange'] = '#FF9000'
|
||||
@ -31,6 +32,11 @@ colors['black'] = '#000000'
|
||||
# line styles for plot():
|
||||
lwthick = 3.0
|
||||
lwthin = 1.8
|
||||
mainline = {'linestyle': '-', 'linewidth': lwthick}
|
||||
minorline = {'linestyle': '-', 'linewidth': lwthin}
|
||||
largemarker = {'marker': 'o', 'markersize': 9, 'markeredgecolor': colors['white'], 'markeredgewidth': 1}
|
||||
smallmarker = {'marker': 'o', 'markersize': 6, 'markeredgecolor': colors['white'], 'markeredgewidth': 1}
|
||||
filllw = 1.0
|
||||
fillalpha = 0.5
|
||||
|
||||
# helper lines:
|
||||
@ -38,30 +44,52 @@ lsSpine = {'c': colors['black'], 'linestyle': '-', 'linewidth': 1}
|
||||
lsGrid = {'c': colors['gray'], 'linestyle': '--', 'linewidth': 1}
|
||||
lsMarker = {'c': colors['black'], 'linestyle': '-', 'linewidth': 2}
|
||||
|
||||
# line styles and fill styles:
|
||||
lsA = {'color': colors['blue'], 'linestyle': '-', 'linewidth': lwthick}
|
||||
lsAm = {'color': colors['blue'], 'linestyle': '-', 'linewidth': lwthin}
|
||||
# line (ls), point (ps), and fill styles (fs).
|
||||
|
||||
# Each style is derived from a main color as indicated by the capital letter.
|
||||
|
||||
# Line styles come in two variants:
|
||||
# - plain style with a thick/solid line (e.g. lsA), and
|
||||
# - minor style with a thinner or dashed line (e.g. lsAm).
|
||||
|
||||
# Point styles come in two variants:
|
||||
# - plain style with large solid markers (e.g. psA), and
|
||||
# - minor style with smaller markers (e.g. lsBm).
|
||||
|
||||
# Fill styles come in three variants:
|
||||
# - plain (e.g. fsB) for a solid fill color and a darker edge color,
|
||||
# - solid (e.g. fsBs) for a solid fill color and without edge color, and
|
||||
# - alpha (e.g. fsBa) for a transparent fill color without edge color.
|
||||
|
||||
lsA = dict({'color': colors['blue']}, **mainline)
|
||||
lsAm = dict({'color': colors['blue']}, **minorline)
|
||||
psA = dict({'color': colors['blue'], 'linestyle': 'none'}, **largemarker)
|
||||
psAm = dict({'color': colors['blue'], 'linestyle': 'none'}, **smallmarker)
|
||||
fsAa = {'facecolor': colors['blue'], 'edgecolor': 'none', 'alpha': fillalpha}
|
||||
|
||||
lsB = {'color': colors['red'], 'linestyle': '-', 'linewidth': lwthick}
|
||||
lsBm = {'color': colors['red'], 'linestyle': '-', 'linewidth': lwthin}
|
||||
fsB = {'facecolor': colors['red'], 'edgecolor': colors['black'], 'linewidth': 1}
|
||||
lsB = dict({'color': colors['red']}, **mainline)
|
||||
lsBm = dict({'color': colors['red']}, **minorline)
|
||||
psB = dict({'color': colors['red'], 'linestyle': 'none'}, **largemarker)
|
||||
psBm = dict({'color': colors['red'], 'linestyle': 'none'}, **smallmarker)
|
||||
fsB = {'facecolor': colors['red'], 'edgecolor': colors['black'], 'linewidth': filllw}
|
||||
fsBs = {'facecolor': colors['red'], 'edgecolor': 'none'}
|
||||
fsBa = {'facecolor': colors['red'], 'edgecolor': 'none', 'alpha': fillalpha}
|
||||
|
||||
lsC = {'color': colors['lightorange'], 'linestyle': '-', 'linewidth': lwthick}
|
||||
lsCm = {'color': colors['lightorange'], 'linestyle': '-', 'linewidth': lwthin}
|
||||
fsC = {'facecolor': colors['lightorange'], 'edgecolor': colors['black'], 'linewidth': 1}
|
||||
lsC = dict({'color': colors['lightorange']}, **mainline)
|
||||
lsCm = dict({'color': colors['lightorange']}, **minorline)
|
||||
psC = dict({'color': colors['lightorange'], 'linestyle': 'none'}, **largemarker)
|
||||
psCm = dict({'color': colors['lightorange'], 'linestyle': 'none'}, **smallmarker)
|
||||
fsC = {'facecolor': colors['lightorange'], 'edgecolor': colors['black'], 'linewidth': filllw}
|
||||
fsCs = {'facecolor': colors['lightorange'], 'edgecolor': 'none'}
|
||||
fsCa = {'facecolor': colors['lightorange'], 'edgecolor': 'none', 'alpha': fillalpha}
|
||||
|
||||
fsD = {'facecolor': colors['orange'], 'edgecolor': colors['black'], 'linewidth': 1}
|
||||
fsD = {'facecolor': colors['orange'], 'edgecolor': colors['black'], 'linewidth': filllw}
|
||||
fsDs = {'facecolor': colors['orange'], 'edgecolor': 'none'}
|
||||
|
||||
fsE = {'facecolor': colors['yellow'], 'edgecolor': colors['black'], 'linewidth': 1}
|
||||
fsE = {'facecolor': colors['yellow'], 'edgecolor': colors['black'], 'linewidth': filllw}
|
||||
fsEs = {'facecolor': colors['yellow'], 'edgecolor': 'none'}
|
||||
|
||||
fsF = {'facecolor': colors['green'], 'edgecolor': colors['black'], 'linewidth': 1}
|
||||
fsF = {'facecolor': colors['green'], 'edgecolor': colors['black'], 'linewidth': filllw}
|
||||
fsFs = {'facecolor': colors['green'], 'edgecolor': 'none'}
|
||||
|
||||
# factor for scaling widths of bars in a bar plot:
|
||||
|
@ -3,8 +3,8 @@ import matplotlib.pyplot as plt
|
||||
import matplotlib.gridspec as gridspec
|
||||
from plotstyle import *
|
||||
|
||||
fig = plt.figure(figsize=cm_size(figure_width, 1.5*figure_height))
|
||||
spec = gridspec.GridSpec(nrows=2, ncols=2, wspace=0.35, hspace=0.35,
|
||||
fig = plt.figure(figsize=cm_size(figure_width, 2.0*figure_height))
|
||||
spec = gridspec.GridSpec(nrows=2, ncols=2, wspace=0.35, hspace=0.5,
|
||||
**adjust_fs(fig, left=5.5, top=0.5, bottom=2.7))
|
||||
rng = np.random.RandomState(2981)
|
||||
n = 200
|
||||
@ -25,6 +25,6 @@ for k, r in enumerate([ 1.0, 0.6, 0.0, -0.9 ]) :
|
||||
ax.set_ylabel('y')
|
||||
ax.set_xlim(-3.0, 3.0)
|
||||
ax.set_ylim(-3.0, 3.0)
|
||||
ax.scatter(x[(np.abs(x)<2.8)&(np.abs(y)<2.8)], y[(np.abs(x)<2.8)&(np.abs(y)<2.8)])
|
||||
ax.plot(x[(np.abs(x)<2.8)&(np.abs(y)<2.8)], y[(np.abs(x)<2.8)&(np.abs(y)<2.8)], **psAm)
|
||||
|
||||
plt.savefig('correlation.pdf')
|
||||
|
@ -15,7 +15,7 @@ gauss = np.exp(-0.5*xx*xx)/np.sqrt(2.0*np.pi)
|
||||
gausscdf = np.cumsum(gauss)*dx
|
||||
|
||||
# plot:
|
||||
fig, ax = plt.subplots()
|
||||
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
|
||||
ax.set_xlabel('x')
|
||||
ax.set_xlim(-3.2, 3.2)
|
||||
ax.set_xticks(np.arange(-3.0, 3.1, 1.0))
|
||||
|
@ -14,7 +14,7 @@ scatterpos = 1.0
|
||||
barpos = 2.5
|
||||
boxpos = 4.0
|
||||
|
||||
fig = plt.figure(figsize=cm_size(figure_width, 1.4*figure_height))
|
||||
fig = plt.figure(figsize=cm_size(figure_width, 1.2*figure_height))
|
||||
spec = gridspec.GridSpec(nrows=1, ncols=2, width_ratios=[3, 1], wspace=0.1,
|
||||
**adjust_fs(fig, left=4.0))
|
||||
|
||||
@ -61,7 +61,7 @@ ax.set_ylim( 0.0, 8.0)
|
||||
kernel = gaussian_kde(data)
|
||||
x = kernel(data)
|
||||
x /= np.max(x)
|
||||
ax.scatter(scatterpos+barwidth*x*(rng.rand(len(data))-0.5), data, s=50)
|
||||
ax.plot(scatterpos+barwidth*x*(rng.rand(len(data))-0.5), data, **psA)
|
||||
|
||||
barmean = np.mean(data)
|
||||
barstd = np.std(data)
|
||||
|
@ -4,6 +4,8 @@ import matplotlib.gridspec as gridspec
|
||||
from plotstyle import *
|
||||
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2)
|
||||
fig.subplots_adjust(wspace=0.35, hspace=0.5,
|
||||
**adjust_fs(fig, left=4, top=0.5, bottom=2.7))
|
||||
|
||||
n = 200
|
||||
rng = np.random.RandomState(3981)
|
||||
@ -18,7 +20,7 @@ ax1.set_xlabel('x')
|
||||
ax1.set_ylabel('y')
|
||||
ax1.set_xlim(-3.0, 3.0)
|
||||
ax1.set_ylim(-0.5, 6.0)
|
||||
ax1.scatter(x, z)
|
||||
ax1.plot(x, z, **psAm)
|
||||
|
||||
z = 0.5*x*y
|
||||
r =np.corrcoef(x,z)[0,1]
|
||||
@ -28,6 +30,6 @@ ax2.set_xlabel('x')
|
||||
ax2.set_ylabel('y')
|
||||
ax2.set_xlim(-3.0, 3.0)
|
||||
ax2.set_ylim(-3.0, 3.0)
|
||||
ax2.scatter(x, z)
|
||||
ax2.plot(x, z, **psAm)
|
||||
|
||||
plt.savefig('nonlincorrelation.pdf')
|
||||
|
@ -8,7 +8,7 @@ g = np.exp(-0.5*x*x)/np.sqrt(2.0*np.pi)
|
||||
x1=0.0
|
||||
x2=1.0
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
|
||||
ax.set_xlabel('x')
|
||||
ax.set_ylabel('Probability density p(x)')
|
||||
ax.set_ylim(0.0, 0.46)
|
||||
|
@ -7,7 +7,7 @@ x = np.arange( -4.0, 4.0, 0.01 )
|
||||
g = np.exp(-0.5*x*x)/np.sqrt(2.0*np.pi)
|
||||
q = [ -0.67488, 0.0, 0.67488 ]
|
||||
|
||||
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.2*figure_height))
|
||||
fig, ax = plt.subplots(figsize=cm_size(figure_width, 1.0*figure_height))
|
||||
fig.subplots_adjust(**adjust_fs(bottom=2.7, top=0.1))
|
||||
ax.set_xlabel('x')
|
||||
ax.set_ylabel('Probability density p(x)')
|
||||
|
Reference in New Issue
Block a user