[statistics] backward compatibility of hist density - still buggy!

This commit is contained in:
Jan Benda 2020-10-27 19:59:26 +01:00
parent d7cbed3a33
commit ca11914956
5 changed files with 20 additions and 7 deletions

View File

@ -2,7 +2,7 @@ import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
xkcd_style = False
xkcd_style = True
# default size of figure:
figure_width = 15.0 # cm, should be set according to \textwidth in the latex document

View File

@ -27,6 +27,9 @@ ax2.set_xlabel('x')
ax2.set_ylim(0, 0.23)
ax2.set_ylabel('Probability')
ax2.plot([0.2, 6.8], [1.0/6.0, 1.0/6.0], zorder=-10, **lsAm)
ax2.hist([x2, x1], bins, density=True, zorder=-5, **fs)
try:
ax2.hist([x2, x1], bins, density=True, zorder=-5, **fs)
except AttributeError:
ax2.hist([x2, x1], bins, normed=True, zorder=-5, **fs)
fig.subplots_adjust(left=0.125)
fig.savefig('diehistograms.pdf')

View File

@ -4,7 +4,7 @@ import matplotlib.gridspec as gridspec
from scipy.stats import gaussian_kde
from plotstyle import *
sketch_style()
#sketch_style()
#rng = np.random.RandomState(981)
#data = rng.randn(40, 1) + 4.0
rng = np.random.RandomState(1981)

View File

@ -44,7 +44,10 @@ ax.set_ylabel('p(x)')
ax.set_ylim(0.0, 0.49)
ax.set_yticks(np.arange(0.0, 0.41, 0.1))
#ax.plot(x, g, '-b', lw=2, zorder=-1)
ax.hist(r, np.arange(-4.1, 4, 0.4), density=True, zorder=-5, **fsC)
try:
ax.hist(r, np.arange(-4.1, 4, 0.4), density=True, zorder=-5, **fsC)
except AttributeError:
ax.hist(r, np.arange(-4.1, 4, 0.4), normed=True, zorder=-5, **fsC)
ax = fig.add_subplot(spec[1, 0])
ax.set_xlabel('x')
@ -54,7 +57,10 @@ ax.set_ylabel('p(x)')
ax.set_ylim(0.0, 0.49)
ax.set_yticks(np.arange(0.0, 0.41, 0.1))
#ax.plot(x, g, '-b', lw=2, zorder=-1)
ax.hist(r, np.arange(-4.3, 4, 0.4), density=True, zorder=-5, **fsC)
try:
ax.hist(r, np.arange(-4.3, 4, 0.4), density=True, zorder=-5, **fsC)
except AttributeError:
ax.hist(r, np.arange(-4.3, 4, 0.4), normed=True, zorder=-5, **fsC)
ax = fig.add_subplot(spec[:, 1])
ax.set_xlabel('x')

View File

@ -24,8 +24,12 @@ ax2.set_ylabel('Probab. density p(x)')
ax2.set_ylim(0.0, 0.44)
ax2.set_yticks(np.arange(0.0, 0.41, 0.1))
ax2.plot(x, g, zorder=-1, **lsA)
ax2.hist(r, 5, density=True, zorder=-10, **fsB)
ax2.hist(r, 20, density=True, zorder=-5, **fsC)
try:
ax2.hist(r, 5, density=True, zorder=-10, **fsB)
ax2.hist(r, 20, density=True, zorder=-5, **fsC)
except AttributeError:
ax2.hist(r, 5, normed=True, zorder=-10, **fsB)
ax2.hist(r, 20, normed=True, zorder=-5, **fsC)
fig.savefig('pdfhistogram.pdf')