Fixed ibox caption and label.

Fixed python pathes.
This commit is contained in:
2015-11-10 10:13:34 +01:00
parent fc8308110b
commit 9525d2995d
6 changed files with 51 additions and 43 deletions

View File

@@ -1,11 +1,11 @@
import matplotlib.pyplot as plt
import numpy as np
from IPython import embed
from matplotlib.transforms import Bbox
def create_data():
m = 0.75
n= -30
x = np.arange(0.,101., 2.5)
n= -40
x = np.arange(5.,115., 2.5)
y = m * x + n;
noise = np.random.randn(len(x))*15
y += noise
@@ -13,79 +13,85 @@ def create_data():
def plot_data(x, y):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5])
ax = plt.gca()
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf()
fig.set_facecolor("white")
fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress.pdf")
plt.tight_layout()
fig.savefig("lin_regress.pdf")
plt.close()
def plot_data_slopes(x, y, m, n):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
for i in np.linspace(m/4, m*1.5, 5):
plt.plot(x, i*x+n, color="r", lw=2)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5])
ax = plt.gca()
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf()
fig.set_facecolor("white")
fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress_slope.pdf")
plt.tight_layout()
fig.savefig("lin_regress_slope.pdf")
plt.close()
def plot_data_intercepts(x, y, m, n):
plt.xkcd()
plt.scatter(x, y, marker='o', color='dodgerblue', s=40)
for i in np.linspace(n-n/2, n+n/2, 5):
plt.plot(x, m * x + i, color="r", lw=2)
plt.xlabel("Input x")
plt.ylabel("Output y")
plt.xlim([-2.5, 102.5])
ax = plt.gca()
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.xaxis.linewidth=1.5
ax.yaxis.linewidth=1.5
ax.tick_params(direction="out", width=1.25)
ax.tick_params(direction="out", width=1.25)
ax.set_xlabel('Input x')
ax.set_ylabel('Output y')
ax.set_xlim(0, 120)
ax.set_ylim(-80, 80)
ax.set_xticks(np.arange(0,121, 40))
ax.set_yticks(np.arange(-80,81, 40))
fig = plt.gcf()
fig.set_facecolor("white")
fig.set_size_inches(3., 3.)
fig.savefig("figures/lin_regress_intercept.pdf")
plt.tight_layout()
fig.savefig("lin_regress_intercept.pdf")
plt.close()
if __name__ == "__main__":
x, y, m, n = create_data()
plt.xkcd()
plot_data(x,y)
plot_data_slopes(x,y,m,n)
plot_data_intercepts(x,y,m,n)

View File

@@ -10,9 +10,9 @@ ein Optimierungsproblem, der besser als Kurvenfit bekannt ist
(\enterm{curve fitting}).
\begin{figure}[tp]
\includegraphics[width=0.32\columnwidth]{lin_regress}\hfill
\includegraphics[width=0.32\columnwidth]{lin_regress_slope}\hfill
\includegraphics[width=0.32\columnwidth]{lin_regress_intercept}
\includegraphics[width=0.33\columnwidth]{lin_regress}\hfill
\includegraphics[width=0.33\columnwidth]{lin_regress_slope}\hfill
\includegraphics[width=0.33\columnwidth]{lin_regress_intercept}
\titlecaption{.}{F\"ur eine Reihe von Eingangswerten $x$,
z.B. Stimulusintensit\"aten, wurden die Antworten $y$ eines
Systems gemessen (links). Der postulierte lineare Zusammenhang hat