Skip to content

Example for sigmoid function with horizontal lines #15914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 16, 2019
Merged

Example for sigmoid function with horizontal lines #15914

merged 7 commits into from
Dec 16, 2019

Conversation

kolibril13
Copy link
Contributor

An example for a sigmoid functions with axhline.
image

@story645
Copy link
Member

Thanks for the PR! While we value your contribution, there is concern that the gallery is getting unwieldy. Can you please explain what this example is demonstrating that is not currently being documented in the gallery?

@kolibril13
Copy link
Contributor Author

Thanks for this kind message.
I was looking for a way to add axes into my plots.
First I found solutions, which suggested
plt.plot([-10, 10], [0, 0], "k-")
but I think that plt.axvline() is more elegant.
From the existing examples in the api, the use case of plt.axvline() as axes is in my optinion not covered.(https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.axvline.html?highlight=axvline#matplotlib.axes.Axes.axvline).
Therefore my idea to add this example.

@jklymak
Copy link
Member

jklymak commented Dec 14, 2019

You could add this to the annotating plots example rather than making a new example.

@kolibril13
Copy link
Contributor Author

@jklymak : Good point.
I think it's a tradeoff between showing only one idea per example and keeping as few examples as possible.
When I am searching for examples, I prefer to have only one thing that gets explained, ready to copy and paste.
I could also add the axvline to the annotation example , like this:
image
However I would prefer to make it a new example.

@jklymak
Copy link
Member

jklymak commented Dec 14, 2019

I think grouping similar functionality into fewer examples makes it easier to find things visually rather than having to search a huge page.

@timhoffm
Copy link
Member

IMHO having a dedicated example for axhline/axvline makes sense. (Annotations are quite something different.) For this purpose, I actually like the proposed example. It contains both cases. It‘s a realistic example but still simple enough. However, the title and description should focus on the purpose; something like „Infinite horizontal and vertical lines“ not „Sigmoid function“. The text should explain what the functions create (the infinite h/v Lines at given y/x coordinates) and what this is commonly used for (indicate special values).

@timhoffm
Copy link
Member

Fake8 issues:

./examples/pyplots/sigmoid_function.py:37:1: E402 module level import not at top of file
./examples/pyplots/sigmoid_function.py:42:1: W391 blank line at end of file

The second one is straight forward to solve. To solve the first one, add

    examples/pyplots/sigmoid_function.py : E402

to the per-file-ignores section of .flake8.

@kolibril13
Copy link
Contributor Author

That was quite a journey.
@timhoffm Thanks a lot for beeing so patient and guiding me through my first pull request to matplotlib. I think I learned a lot, and hopefully apply this knowledge very soon.

@timhoffm
Copy link
Member

I took the liberty to push a commit renaming the file from sigmoid_function.py to axline.py. - I intend to expand the example with (or at least mention) the recently added axline() function.

Will squash-merge after CI pass.

Thanks a lot, and congratulations on your first contribution to Matplotlib! Hope to see you back some time.

@timhoffm timhoffm added this to the v3.2.0 milestone Dec 16, 2019
@timhoffm timhoffm merged commit bebd7f1 into matplotlib:master Dec 16, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 17, 2019
timhoffm added a commit that referenced this pull request Dec 17, 2019
…914-on-v3.2.x

Backport PR #15914 on branch v3.2.x (Example for sigmoid function with horizontal lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants