-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Logit scale, changes in LogitLocator and LogitFormatter #14512
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e736500
ticker: introduce atol/rtol for comparisons
jb-leger 5847a84
logitscale: rewrite of LogitLocator
jb-leger adc30ed
logitscale: rewrite of LogitFormatter
jb-leger 4891fbf
logitscale: tests, helpers for TestLogitLocator TestLogitFormatter
jb-leger 584705e
logitscale: tests, rewrite of TestLogitLocator
jb-leger 98e670d
logitscale: tests, creation of TestLogitFormatter
jb-leger 851fa4a
logitscale: add option to LogitScale, passed to LogitFormatter
jb-leger c1360bb
logitscale: remove hack in doc to workround the formatter, it is not …
jb-leger 4717b46
logitscale: add new example to illustrate logitscale
jb-leger 6524de2
logitscale: add whatsnew entry
jb-leger e3c8e25
logitscale: typos in whats news entry.
jb-leger eb955d7
logitscale: typos and documentation convention in LogitScale
jb-leger f68f903
logitscale: typos and documentation convention in LogitFormatter
jb-leger e113aff
logitscale: documentation reformulation and typo in LogitFormatter
jb-leger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Improvements in Logit scale ticker and formatter | ||
------------------------------------------------ | ||
|
||
Introduced in version 1.5, the logit scale didn't have an appropriate ticker and | ||
formatter. Previously, the location of ticks was not zoom dependent, too many labels | ||
were displayed causing overlapping which broke readability, and label formatting | ||
did not adapt to precision. | ||
|
||
Starting from this version, the logit locator has nearly the same behavior as the | ||
locator for the log scale or the linear | ||
scale, depending on used zoom. The number of ticks is controlled. Some minor | ||
labels are displayed adaptively as sublabels in log scale. Formatting is adapted | ||
for probabilities and the precision is adapts to the scale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
================ | ||
Logit Demo | ||
================ | ||
|
||
Examples of plots with logit axes. | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
xmax = 10 | ||
x = np.linspace(-xmax, xmax, 10000) | ||
cdf_norm = np.array([np.math.erf(w / np.sqrt(2)) / 2 + 1 / 2 for w in x]) | ||
cdf_laplacian = np.array( | ||
[1 / 2 * np.exp(w) if w < 0 else 1 - 1 / 2 * np.exp(-w) for w in x] | ||
) | ||
cdf_cauchy = 1 / np.pi * np.arctan(x) + 1 / 2 | ||
|
||
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(6.4, 8.5)) | ||
|
||
# Common part, for the example, we will do the same plots on all graphs | ||
for i in range(3): | ||
for j in range(2): | ||
axs[i, j].plot(x, cdf_norm, label=r"$\mathcal{N}$") | ||
axs[i, j].plot(x, cdf_laplacian, label=r"$\mathcal{L}$") | ||
axs[i, j].plot(x, cdf_cauchy, label="Cauchy") | ||
axs[i, j].legend() | ||
axs[i, j].grid() | ||
|
||
# First line, logitscale, with standard notation | ||
axs[0, 0].set(title="logit scale") | ||
axs[0, 0].set_yscale("logit") | ||
axs[0, 0].set_ylim(1e-5, 1 - 1e-5) | ||
|
||
axs[0, 1].set(title="logit scale") | ||
axs[0, 1].set_yscale("logit") | ||
axs[0, 1].set_xlim(0, xmax) | ||
axs[0, 1].set_ylim(0.8, 1 - 5e-3) | ||
|
||
# Second line, logitscale, with survival notation (with `use_overline`), and | ||
# other format display 1/2 | ||
axs[1, 0].set(title="logit scale") | ||
axs[1, 0].set_yscale("logit", one_half="1/2", use_overline=True) | ||
axs[1, 0].set_ylim(1e-5, 1 - 1e-5) | ||
|
||
axs[1, 1].set(title="logit scale") | ||
axs[1, 1].set_yscale("logit", one_half="1/2", use_overline=True) | ||
axs[1, 1].set_xlim(0, xmax) | ||
axs[1, 1].set_ylim(0.8, 1 - 5e-3) | ||
|
||
# Third line, linear scale | ||
axs[2, 0].set(title="linear scale") | ||
axs[2, 0].set_ylim(0, 1) | ||
|
||
axs[2, 1].set(title="linear scale") | ||
axs[2, 1].set_xlim(0, xmax) | ||
axs[2, 1].set_ylim(0.8, 1) | ||
|
||
fig.tight_layout() | ||
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rendered example is at https://22432-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/gallery/scales/logit_demo.html#sphx-glr-gallery-scales-logit-demo-py; you may want to play with e.g. figsize a bit...$\frac{1}{2}$ is that nice, perhaps 1/2 would look better?
Also, looking at the example I wonder whether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. There is a way to build the html locally?
For one half, I prefer$\frac{1}{2}$ , but it is a personal pov, I can put the choice in a option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see https://matplotlib.org/devel/documenting_mpl.html#building-the-docs.
I'll let the next reviewer (we need two to merge) decide on whether to insist on an API for 1/2 vs. \frac...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the link.
I think both choice should be proposed, but we still have to decide the default choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's your PR, you get to pick, unless the other reviewer agrees with me that 1/2 is better :)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The graph in example should be fixed now.
I have added a option to choose the string for one half. It is illustrated in the example. I can change the default choice. I keep this thread open.