Repository navigation
Conversation
efiring
left a comment
There was a problem hiding this comment.
Thank you for filling in this gap in colorbar.
| if self.logscale: | ||
| tempLocator = LogLocator() | ||
| if self.locator is not None: | ||
| tempLocator = self.locator |
There was a problem hiding this comment.
Instead of using a temporary Locator and then requiring that all Locators have 3 new private methods, I think it would be better to keep everything within the ContourBase class. This will be more readable than using Locator private methods that modify one of their arguments. It will likely require fewer LOC as well.
There was a problem hiding this comment.
@efiring Thank you for the input. I took sometimes to think it over more carefully, I will fix it your way.
| assert cb._values[0] >= 0.0 | ||
|
|
||
|
|
||
| @image_comparison(baseline_images=['extended_cbar_with_contourf_min', |
There was a problem hiding this comment.
Please condense the test down to a single image with 3 subplots, saving time and space.
| 'extended_cbar_with_contourf_both'], | ||
| extensions=['png']) | ||
| def test_extended_colorbar_on_contourf(): | ||
| np.random.seed(1) |
| x = np.linspace(-3.0, 3.0, N) | ||
| y = np.linspace(-2.0, 2.0, N) | ||
| X, Y = np.meshgrid(x, y) | ||
| z = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) |
There was a problem hiding this comment.
For the purpose of a test you can use a simpler pattern with far fewer points. For example, you could use
z = np.logspace(0.1, 10, 24).reshape((4, 6))and omit the X and Y entirely.
| plt.subplot(111) | ||
| plt.contourf(X, Y, z, cmap=cm.PuBu_r, locator=ticker.LogLocator(), | ||
| extend='min') | ||
| plt.colorbar() |
There was a problem hiding this comment.
For condensing the example you can use fig, axs = plt.subplots(ncols=3) and then use Axes and Figure method calls.
|
Here is what I came up with: |
|
Yes. That can work. But shouldn't self._levels be scaled with whatever base of LogNorm? I.e lamda x: x*some_base ? LogNorm takes more than 1 bases and self._levels is used in calculating rgba. I mean when firing up debugger, I see values of |
|
No, just as the value added or subtracted in the linear case (1) is arbitrary, so long as it is positive, the multiplier or divisor in the log case is also arbitrary, so long as it is greater than 1. It merely needs to push the level outside the normed range so that the "under" and "over" colors of the colormap are used. |
|
Ah. I see. Thanks for clarifying that. I think your implementation is better. Please commit it. |
|
@Tuan333 did you mean to close this and delete your branch? |
|
I haven't made an alternative PR yet, but I have committed the implementation suggested above. I find that specifying a LogLocator really doesn't do anything sensible at present, regardless of the extend kwarg. I think I have a fix for that, and to be consistent it will also make an improvement in the case with no locator specified and with the extend kwarg. I think this is a rare use case, so I'm not too worried about the behavior change. |
|
@efiring @tacaswell oops... I thought this is not needed anymore and moved on to some other bugs I'm interested in. Should I have left this open? (genuine mistake/question) |
|
I think closing it is fine. If you don't see a PR from me on this within a week, ping me. |
PR Summary
Implement extend keyword for lognorm color bar on contourf. Travis ci might sometimes timeout during installation (before testing starts) and fails.
PR Checklist