Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Uptade fix number of levels with log contour#29137
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -960,13 +960,12 @@ | ||
label.set_color(self.labelMappable.to_rgba(cv)) | ||
super().changed() | ||
def _autolev(self, N, *, using_default): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think this extra argument is not necessary. The only place where this is passed it is simply a So even if the variable is useful, it can be computed internally. However, even further, the difference between Haven't fully thought through the last portion (adjustments if levels are still insufficient) and if there may need to be at least a | ||
""" | ||
Select contour levels to span the data. | ||
The target number of levels, *N*, is used only when the | ||
locator is notset andthe scale islog or the default | ||
locator is used. | ||
We need two more levels for filled contours than for | ||
line contours, because for the latter we need to specify | ||
the lower and upper boundary of each range. For example, | ||
@@ -976,7 +975,12 @@ | ||
""" | ||
if self.locator is None: | ||
if self.logscale: | ||
if using_default: | ||
# Let log locator choose instead of using hard coded value | ||
# set in self._process_contour_level_args() | ||
self.locator = ticker.LogLocator() | ||
else: | ||
self.locator = ticker.LogLocator(numticks=N) | ||
else: | ||
self.locator = ticker.MaxNLocator(N + 1, min_n_ticks=1) | ||
@@ -993,14 +997,25 @@ | ||
i0 = under[-1] if len(under) else 0 | ||
over = np.nonzero(lev > self.zmax)[0] | ||
i1 = over[0] + 1 if len(over) else len(lev) | ||
if self.extend in ('min', 'both'): | ||
i0 += 1 | ||
if self.extend in ('max', 'both'): | ||
i1 -= 1 | ||
# Ensure at least 3 levels and handle log scale specifically | ||
if i1 - i0 < 3: | ||
i0, i1 = 0, len(lev) | ||
# Handle log scale adjustments if levels are still insufficient | ||
if self.logscale and len(lev) < N: | ||
self.locator = ticker.LogLocator(numticks=N+1) | ||
lev = self.locator.tick_values(self.zmin, self.zmax) | ||
under = np.nonzero(lev < self.zmin)[0] | ||
i0 = under[-1] if len(under) else 0 | ||
over = np.nonzero(lev > self.zmax)[0] | ||
i1 = over[0] + 1 if len(over) else len(lev) | ||
return lev[i0:i1] | ||
def _process_contour_level_args(self, args, z_dtype): | ||
@@ -1020,7 +1035,7 @@ | ||
else: | ||
levels_arg = self.levels | ||
if isinstance(levels_arg, Integral): | ||
self.levels = self._autolev(levels_arg, using_default=self.levels is None) | ||
else: | ||
self.levels = np.asarray(levels_arg, np.float64) | ||
if self.filled and len(self.levels) < 2: | ||
Uh oh!
There was an error while loading.Please reload this page.