From f1883dda3bdf1557cc29c7b6f5d73c5d2786eb49 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Wed, 11 Dec 2019 23:29:54 +0100 Subject: [PATCH 1/7] Example for sigmoid function with horizontal lines --- examples/pyplots/sigmoid_function.py | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/pyplots/sigmoid_function.py diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/sigmoid_function.py new file mode 100644 index 000000000000..05ab57ecc887 --- /dev/null +++ b/examples/pyplots/sigmoid_function.py @@ -0,0 +1,33 @@ +""" +============ +Sigmoid Function +============ +A script that showes the sigmoid function with horizontal lines for emphasis of important values. +""" +import numpy as np +import matplotlib.pyplot as plt +t = np.linspace(-10, 10, 100) +sig = 1 / (1 + np.exp(-t)) +plt.figure(figsize=(9, 5)) +plt.axhline(c="k") +plt.axvline(c="k") +plt.axhline(y=0.5,c="k", ls = ":") +plt.axhline(y=1.0,c="k", ls = ":") +plt.plot(t, sig, "b-", linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$") +plt.xlabel("t") +plt.legend(loc="upper left", fontsize=20) +plt.show() + +############################################################################# +# +# ------------ +# +# References +# """""""""" +# +# The use of the following functions, methods, classes and modules is shown +# in this example: + +import matplotlib +matplotlib.axes.Axes.axhline +matplotlib.axes.Axes.axvline From 8874536235cf30893673f255a1f01453b7b3ec8f Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sun, 15 Dec 2019 17:14:07 +0100 Subject: [PATCH 2/7] simplified script and changed title --- examples/pyplots/sigmoid_function.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/sigmoid_function.py index 05ab57ecc887..968459608ecc 100644 --- a/examples/pyplots/sigmoid_function.py +++ b/examples/pyplots/sigmoid_function.py @@ -1,21 +1,23 @@ """ ============ -Sigmoid Function +Infinite horizontal and vertical lines ============ -A script that showes the sigmoid function with horizontal lines for emphasis of important values. +A script that showes the infinite horizontal and vertical lines together with a sigmoid function. """ import numpy as np import matplotlib.pyplot as plt + t = np.linspace(-10, 10, 100) sig = 1 / (1 + np.exp(-t)) -plt.figure(figsize=(9, 5)) -plt.axhline(c="k") -plt.axvline(c="k") -plt.axhline(y=0.5,c="k", ls = ":") -plt.axhline(y=1.0,c="k", ls = ":") -plt.plot(t, sig, "b-", linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$") + +plt.axhline(y=0, color="black", linestyle="--") +plt.axhline(y=0.5, color="black", linestyle=":") +plt.axhline(y=1.0, color="black", linestyle="--") +plt.axvline(color="grey") +plt.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$") +plt.xlim(-10, 10) plt.xlabel("t") -plt.legend(loc="upper left", fontsize=20) +plt.legend(fontsize=14) plt.show() ############################################################################# From e9538b3283330e754da8414e36fd4cef6bc88093 Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sun, 15 Dec 2019 17:15:04 +0100 Subject: [PATCH 3/7] fixed typo --- examples/pyplots/sigmoid_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/sigmoid_function.py index 968459608ecc..5f9f9ec02718 100644 --- a/examples/pyplots/sigmoid_function.py +++ b/examples/pyplots/sigmoid_function.py @@ -2,7 +2,7 @@ ============ Infinite horizontal and vertical lines ============ -A script that showes the infinite horizontal and vertical lines together with a sigmoid function. +A script that showes infinite horizontal and vertical lines together with a sigmoid function. """ import numpy as np import matplotlib.pyplot as plt From eb2647f4ee615c0d113a0e5ae82cc295f6b7599b Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sun, 15 Dec 2019 18:46:56 +0100 Subject: [PATCH 4/7] Fixing heading markup and specifying purpose of plot --- examples/pyplots/sigmoid_function.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/sigmoid_function.py index 5f9f9ec02718..590195d70a74 100644 --- a/examples/pyplots/sigmoid_function.py +++ b/examples/pyplots/sigmoid_function.py @@ -1,8 +1,12 @@ """ -============ +====================================== Infinite horizontal and vertical lines -============ -A script that showes infinite horizontal and vertical lines together with a sigmoid function. +====================================== + +`~.axes.Axes.axvline` and `~.axes.Axes.axhline` draw infinite vertical / +horizontal lines, at given *x* / *y* positions. They are usually used to mark +special data values, e.g. in this example the center and limit values of the +sigmoid function. """ import numpy as np import matplotlib.pyplot as plt @@ -31,5 +35,8 @@ # in this example: import matplotlib +matplotlib.pyplot.axhline +matplotlib.pyplot.axvline matplotlib.axes.Axes.axhline matplotlib.axes.Axes.axvline + From ede48006d485336bf1057aee56418f198c6f0a1b Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sun, 15 Dec 2019 23:11:16 +0100 Subject: [PATCH 5/7] remove blank line --- examples/pyplots/sigmoid_function.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/sigmoid_function.py index 590195d70a74..73eed0752c7d 100644 --- a/examples/pyplots/sigmoid_function.py +++ b/examples/pyplots/sigmoid_function.py @@ -39,4 +39,3 @@ matplotlib.pyplot.axvline matplotlib.axes.Axes.axhline matplotlib.axes.Axes.axvline - From 0121bb25c43b16e30e0f1dc524e7511aec1b397e Mon Sep 17 00:00:00 2001 From: kolibril13 <44469195+kolibril13@users.noreply.github.com> Date: Sun, 15 Dec 2019 23:15:06 +0100 Subject: [PATCH 6/7] added per-file-ignores sigmoid_function.py : E402 --- .flake8 | 1 + 1 file changed, 1 insertion(+) diff --git a/.flake8 b/.flake8 index 51aacc2338a4..5816e996bcce 100644 --- a/.flake8 +++ b/.flake8 @@ -216,6 +216,7 @@ per-file-ignores = examples/pyplots/whats_new_99_axes_grid.py: E402 examples/pyplots/whats_new_99_mplot3d.py: E402 examples/pyplots/whats_new_99_spines.py: E231, E402 + examples/pyplots/sigmoid_function.py : E402 examples/recipes/placing_text_boxes.py: E501 examples/scales/power_norm.py: E402 examples/scales/scales.py: E402 From 3c91c811b38781bc8fc5046fbd6230632be7d817 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 16 Dec 2019 23:55:37 +0100 Subject: [PATCH 7/7] Rename example file sigmoid_function.py to axline.py --- .flake8 | 2 +- examples/pyplots/{sigmoid_function.py => axline.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/pyplots/{sigmoid_function.py => axline.py} (100%) diff --git a/.flake8 b/.flake8 index 5816e996bcce..c4a86da4714c 100644 --- a/.flake8 +++ b/.flake8 @@ -195,6 +195,7 @@ per-file-ignores = examples/pyplots/annotation_basic.py: E402 examples/pyplots/annotation_polar.py: E231, E402 examples/pyplots/auto_subplots_adjust.py: E231, E302, E402 + examples/pyplots/axline.py: E402 examples/pyplots/boxplot_demo_pyplot.py: E231, E402 examples/pyplots/compound_path_demo.py: E231 examples/pyplots/dollar_ticks.py: E402 @@ -216,7 +217,6 @@ per-file-ignores = examples/pyplots/whats_new_99_axes_grid.py: E402 examples/pyplots/whats_new_99_mplot3d.py: E402 examples/pyplots/whats_new_99_spines.py: E231, E402 - examples/pyplots/sigmoid_function.py : E402 examples/recipes/placing_text_boxes.py: E501 examples/scales/power_norm.py: E402 examples/scales/scales.py: E402 diff --git a/examples/pyplots/sigmoid_function.py b/examples/pyplots/axline.py similarity index 100% rename from examples/pyplots/sigmoid_function.py rename to examples/pyplots/axline.py