You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug fix for pcolorfast to allow direct color #1317
this way one can pass [nx,ny,3] or [nx,ny,4] arrays to the routine - for
which the PcolorImage it calls is made (style == "pcolorimage")
-Alexander
From e555f98ca915eb89c7df1cff21261efb506fc29a Mon Sep 17 00:00:00 2001
From: Alexander Heger matplotlib@2sn.net
Date: Fri, 28 Sep 2012 15:08:27 +1000
Subject: [PATCH] BF - fix pcolor fast to allow direct color
diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py
index 56017a2..6a4a87d 100644
--- a/lib/matplotlib/axes.py
+++ b/lib/matplotlib/axes.py
@@ -7582,7 +7582,7 @@ class Axes(martist.Artist):
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
C = args[-1]
nr, nc = C.shape
nr, nc = C.shape[:2]
if len(args) == 1:
style = "image"
x = [0, nc]
What you are calling a "bug" is not a bug, it is simply part of the present design of the pcolor family, including pcolormesh and pcolorfast. These methods are presently designed to be quite similar in their inputs, and to accept color-mapped inputs only, not arrays of RGB or RGBA. Changing that might or might not be a good idea, but it is certainly not trivial.
As an alternative, or in addition, one could add methods (and pyplot functions) for NonUniformImage and PcolorImage, which could accept RGB or RGBA arrays directly.
For pcolorfast, the sticking point is the case where the pcolormesh method is used. It uses a Quadmesh, which is a collection, and at present collections in general are not designed to handle anything other than color mapping. I suspect this is not terribly hard to change, but it would require some thought, care, and testing.
the point is that if you just add these 4 characters, pcolorfast can use
n x m * [3|4] arrays. It won't break anything else adding these, so
why not add it and make my application work? I assume it would be
useful to other as well.
I use of for the case "pcolorimage" where x and y are just vectors.
It really is just this one change that is an oversight to make things
work more general in this routine, fixing the other methods can be done
later independently and I am happy to have a look and try to fix it; it
may need some testing on various platforms and cases outside of what I
can access.
But I have to admit so far I am rather discouraged to never receive any
positive feedback on obvious easy additions I have proposed. The
developer circle seems pretty closed. And I would have liked to add
many things ... what can I do?
Yes, it would be good to change in general, in fact I plan to implement
a different approach using colour functions instead of tables, something
I did in IDL and would like to keep.
Best wishes,
Alexander
On 28/09/12 16:56, Eric Firing wrote:
What you are calling a "bug" is not a bug, it is simply part of the
present design of the pcolor family, including pcolormesh and
pcolorfast. These methods are presently designed to be quite similar in
their inputs, and to accept color-mapped inputs only, not arrays of RGB
or RGBA. Changing that might or might not be a good idea, but it is
certainly not trivial.
As an alternative, or in addition, one could add methods (and pyplot
functions) for NonUniformImage and PcolorImage, which could accept RGB
or RGBA arrays directly.
For pcolorfast, the sticking point is the case where the pcolormesh
method is used. It uses a Quadmesh, which is a collection, and at
present collections in general are not designed to handle anything other
than color mapping. I suspect this is not terribly hard to change, but
it would require some thought, care, and testing.
—
Reply to this email directly or view it on GitHub #1317 (comment).
Adding those 4 characters would make pcolorfast work on n x m x (3/4) arrays for some inputs, not for others (those that trigger quadmesh rendering). At the very least this inconsistency would need to be noted in the docstring. I see your point that it would not break any existing code, so it is tempting in that sense. I will reconsider.
I don't recall any of your previous suggestions, but I think that if you look through the git history, you will see that there have been many mpl contributors, so I don't agree with your assertion that the "developer circle seems pretty closed".
Adding those 4 characters would make pcolorfast work on n x m x (3/4)
arrays for some inputs, not for others (those that trigger quadmesh
rendering). At the very least this inconsistency would need to be noted
in the docstring. I see your point that it would not break any existing
code, so it is tempting in that sense. I will reconsider.
yes, it would trigger an exception for those cases where the method does
not support direct colour. Those would need to be fixed later if
anybody want to use them, I am happy to have a look if there is interest.
But now it triggers an exception for the "pcolorimage" where all else
would work fine already. This is why I urge you to do it - it completes
a new feature at essentially no cost (unless someone really had built
code that relies on pcolorfast throwing en exception in that case).
If one wants to add this for the other methods in pcolorfast at a later
time, this is the first step as well.
I don't recall any of your previous suggestions, but I think that if you
look through the git history, you will see that there have been many mpl
contributors, so I don't agree with your assertion that the "developer
circle seems pretty closed".
no, I had a suggestion on text alignment, an addition that also would
not have broken anything existing. Just added a new feature. I have
written now some extra code that actually solved some of the questions
that came up in the discussion - this was very useful - but they add new
kw parameters and are a bigger change but add a missing part halful for
aligning text symbol markers - I don't want to go through the trouble of
making a patch for this if all my submissions are just rejected. The
original patch, though its shortcomings, is still the only "natural"
extension of the exiting code and should go in as is.
I could also add some fixes to descriptions/documentation, etc., as I go
through the code, which I think should be useful as well.
I just thinks it would be useful that if I fix things this goes back
into the general repository. BTW, I have not found a good description
on how to add new examples to show new features or recipes for how to do
things.
Alexander, it has been a while since you last replied. Are you still intending to put together a PR for this feature you wish to add? I am not against such a feature, provided that it includes all of the appropriate changes to documentation and test cases.
I am still a little confused about the use-case, but I would be willing to review it when I see the entire change all at once. Note, the feature freeze for v1.2.0 has long since past, so if you were trying to get this in for that, it wasn't going to happen anyway.
I have been on travel for the last 2 weeks and still have about half a
week to go (incl. 24h travel from US tu AU).
Well, the change is really just adding a four characters in one line and
no documented feature breaks. Do you really need a PR for that? The
online development documentation suggests to send small changes to the
list - maybe that needs to be updated - but I can generate a PR when I
am back.
1.2 is not critical for me, I use the master branch anyway, but it would
be good to see this added to the development.
The use case is that you can provide your own image data in RGB[A]
format already and not use the current colormap feature. It allows very
different kind of visualization - you can use all 2**24 colors. Or once
could add the alpha channel for partial transparency in select regions.
For example, imaging to use color (hue) for direction of a flow and
saturation for the magnitude of velocity (just an example, it does not
work well - of course they need to be translated to RGB from HSL).
In any case, it does not break anything old, adds capability, and does
not require opaque changes to the code.
Best wishes,
Alexander
On 13/10/12 21:02, Benjamin Root wrote:
Alexander, it has been a while since you last replied. Are you still
intending to put together a PR for this feature you wish to add? I
am not against such a feature, provided that it includes all of the
appropriate changes to documentation and test cases.
I am still a little confused about the use-case, but I would be
willing to review it when I see the entire change all at once. Note,
the feature freeze for v1.2.0 has long since past, so if you were
trying to get this in for that, it wasn't going to happen anyway.
--- Reply to this email directly or view it on GitHub: #1317 (comment)
On Sunday, October 14, 2012, Alexander Heger wrote:
Dear Benjamin,
I have been on travel for the last 2 weeks and still have about half a
week to go (incl. 24h travel from US tu AU).
Well, the change is really just adding a four characters in one line and
no documented feature breaks. Do you really need a PR for that?
We need a PR for the change, plus docs, plus tests. If we start adding
small features here and there with the promise of future documentation, we
will have lots of things accidentally breaking in the future whenever
someone makes an innocuous change.
It isn't that it is 4 character change. It is that matplotlib is so big!
Remember, open source is very much about scratching your own itch. I have
plenty of my own itches to scratch, so unless someone else has the same
itch as yours, you should expect to shepard your patch through.
As for the docs, perhaps that should be clarified. Your change is small, at
first, but it is incomplete. When completed, it is something that should
be a PR.
The use case is that you can provide your own image data in RGB[A]
format already and not use the current colormap feature. It allows very
different kind of visualization - you can use all 2**24 colors. Or once
could add the alpha channel for partial transparency in select regions.
Why not use imshow() for this? Is your grid irregular?
Cheers!
Ben Root
Z = np.ndarray(ZR.shape + (4,))
Z[...,0] = ZR /ZR.max()
Z[...,1] = ZG /ZG.max()
Z[...,2] = ZB /ZB.max()
Z[...,3] = np.exp(-ZA /ZA.max())
Z = (Z*255).astype(np.uint8)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
i = ax.pcolorfast(x, y, Z)
# from matplotlib.image import PcolorImage
# i = PcolorImage(ax, x, y, Z)
# ax.images.append(i)
# xl, xr, yb, yt = x[0], x[-1], y[0], y[-1]
# ax.update_datalim(np.array([[xl, yb], [xr, yt]]))
# ax.autoscale_view(tight=True)
plt.show()
On 13/10/12 21:02, Benjamin Root wrote:
Alexander, it has been a while since you last replied. Are you still intending to put together a PR for this feature you wish to add? I am not against such a feature, provided that it includes all of the appropriate changes to documentation and test cases.
I am still a little confused about the use-case, but I would be willing to review it when I see the entire change all at once. Note, the feature freeze for v1.2.0 has long since past, so if you were trying to get this in for that, it wasn't going to happen anyway.
Reply to this email directly or view it on GitHub: #1317 (comment)
OK, I will update the documentation as well and generate a PR.
yes, I want to plot large non-uniform images.
(NonUniformImage is too slow)
Best wishes,
Alexander
PS - I did have another pull request on text alignment that came with
documentation, I think that is still pending as well. There was some
discussion on github, but here was no better solution (my assessment) on
generalizing text aliment; I plan to submit another PR that will provide
a solution for text aligned with fixed-sized markers but require 2 new
keywords to text - this is what I tried to avoid.
On 13/10/12 23:36, Benjamin Root wrote:
Alex,
On Sunday, October 14, 2012, Alexander Heger wrote:
Dear Benjamin,
I have been on travel for the last 2 weeks and still have about half a
week to go (incl. 24h travel from US tu AU).
Well, the change is really just adding a four characters in one line and
no documented feature breaks. Do you really need a PR for that?
We need a PR for the change, plus docs, plus tests. If we start adding
small features here and there with the promise of future documentation, we
will have lots of things accidentally breaking in the future whenever
someone makes an innocuous change.
It isn't that it is 4 character change. It is that matplotlib is so big!
Remember, open source is very much about scratching your own itch. I have
plenty of my own itches to scratch, so unless someone else has the same
itch as yours, you should expect to shepard your patch through.
As for the docs, perhaps that should be clarified. Your change is small, at
first, but it is incomplete. When completed, it is something that should
be a PR.
The use case is that you can provide your own image data in RGB[A]
format already and not use the current colormap feature. It allows very
different kind of visualization - you can use all 2**24 colors. Or once
could add the alpha channel for partial transparency in select regions.
Why not use imshow() for this? Is your grid irregular?
Cheers!
Ben Root
Reply to this email directly or view it on GitHub: #1317 (comment)
@2sn I think there is interest in a PR to implement this. We are triaging for 1.4.0 now, so if you can get it in soon (with in a week) then we can try to get it in.
@2snhttps://github.com/2sn I think there is interest in a PR to
implement this. We are triaging for 1.4.0 now, so if you can get it in soon
(with in a week) then we can try to get it in.
Reply to this email directly or view it on GitHubhttps://github.com//issues/1317#issuecomment-36530192
.
Unfortunately I am too much overloaded with proposals and teaching this
week.
-Alexander
On 04/03/14 03:49, Thomas A Caswell wrote:
@2sn I think there is interest in a PR to implement this. We are triaging for 1.4.0 now, so if you can get it in soon (with in a week) then we can try to get it in.
Reply to this email directly or view it on GitHub: #1317 (comment)
Activity
efiring commentedon Sep 28, 2012
What you are calling a "bug" is not a bug, it is simply part of the present design of the pcolor family, including pcolormesh and pcolorfast. These methods are presently designed to be quite similar in their inputs, and to accept color-mapped inputs only, not arrays of RGB or RGBA. Changing that might or might not be a good idea, but it is certainly not trivial.
As an alternative, or in addition, one could add methods (and pyplot functions) for NonUniformImage and PcolorImage, which could accept RGB or RGBA arrays directly.
For pcolorfast, the sticking point is the case where the pcolormesh method is used. It uses a Quadmesh, which is a collection, and at present collections in general are not designed to handle anything other than color mapping. I suspect this is not terribly hard to change, but it would require some thought, care, and testing.
2sn commentedon Sep 28, 2012
Dear Eric,
the point is that if you just add these 4 characters, pcolorfast can use
n x m * [3|4] arrays. It won't break anything else adding these, so
why not add it and make my application work? I assume it would be
useful to other as well.
I use of for the case "pcolorimage" where x and y are just vectors.
It really is just this one change that is an oversight to make things
work more general in this routine, fixing the other methods can be done
later independently and I am happy to have a look and try to fix it; it
may need some testing on various platforms and cases outside of what I
can access.
But I have to admit so far I am rather discouraged to never receive any
positive feedback on obvious easy additions I have proposed. The
developer circle seems pretty closed. And I would have liked to add
many things ... what can I do?
Yes, it would be good to change in general, in fact I plan to implement
a different approach using colour functions instead of tables, something
I did in IDL and would like to keep.
Best wishes,
Alexander
On 28/09/12 16:56, Eric Firing wrote:
efiring commentedon Sep 28, 2012
Adding those 4 characters would make pcolorfast work on n x m x (3/4) arrays for some inputs, not for others (those that trigger quadmesh rendering). At the very least this inconsistency would need to be noted in the docstring. I see your point that it would not break any existing code, so it is tempting in that sense. I will reconsider.
I don't recall any of your previous suggestions, but I think that if you look through the git history, you will see that there have been many mpl contributors, so I don't agree with your assertion that the "developer circle seems pretty closed".
2sn commentedon Sep 28, 2012
Dear Eric,
yes, it would trigger an exception for those cases where the method does
not support direct colour. Those would need to be fixed later if
anybody want to use them, I am happy to have a look if there is interest.
But now it triggers an exception for the "pcolorimage" where all else
would work fine already. This is why I urge you to do it - it completes
a new feature at essentially no cost (unless someone really had built
code that relies on pcolorfast throwing en exception in that case).
If one wants to add this for the other methods in pcolorfast at a later
time, this is the first step as well.
no, I had a suggestion on text alignment, an addition that also would
not have broken anything existing. Just added a new feature. I have
written now some extra code that actually solved some of the questions
that came up in the discussion - this was very useful - but they add new
kw parameters and are a bigger change but add a missing part halful for
aligning text symbol markers - I don't want to go through the trouble of
making a patch for this if all my submissions are just rejected. The
original patch, though its shortcomings, is still the only "natural"
extension of the exiting code and should go in as is.
I could also add some fixes to descriptions/documentation, etc., as I go
through the code, which I think should be useful as well.
I just thinks it would be useful that if I fix things this goes back
into the general repository. BTW, I have not found a good description
on how to add new examples to show new features or recipes for how to do
things.
Best wishes,
Alexander
2sn commentedon Sep 28, 2012
The previous code suggestions was a pull request entitled "NF - Text numeric values for ha and va".
WeatherGod commentedon Oct 14, 2012
Alexander, it has been a while since you last replied. Are you still intending to put together a PR for this feature you wish to add? I am not against such a feature, provided that it includes all of the appropriate changes to documentation and test cases.
I am still a little confused about the use-case, but I would be willing to review it when I see the entire change all at once. Note, the feature freeze for v1.2.0 has long since past, so if you were trying to get this in for that, it wasn't going to happen anyway.
2sn commentedon Oct 14, 2012
Dear Benjamin,
I have been on travel for the last 2 weeks and still have about half a
week to go (incl. 24h travel from US tu AU).
Well, the change is really just adding a four characters in one line and
no documented feature breaks. Do you really need a PR for that? The
online development documentation suggests to send small changes to the
list - maybe that needs to be updated - but I can generate a PR when I
am back.
1.2 is not critical for me, I use the master branch anyway, but it would
be good to see this added to the development.
The use case is that you can provide your own image data in RGB[A]
format already and not use the current colormap feature. It allows very
different kind of visualization - you can use all 2**24 colors. Or once
could add the alpha channel for partial transparency in select regions.
For example, imaging to use color (hue) for direction of a flow and
saturation for the magnitude of velocity (just an example, it does not
work well - of course they need to be translated to RGB from HSL).
In any case, it does not break anything old, adds capability, and does
not require opaque changes to the code.
Best wishes,
Alexander
On 13/10/12 21:02, Benjamin Root wrote:
WeatherGod commentedon Oct 14, 2012
Alex,
On Sunday, October 14, 2012, Alexander Heger wrote:
We need a PR for the change, plus docs, plus tests. If we start adding
small features here and there with the promise of future documentation, we
will have lots of things accidentally breaking in the future whenever
someone makes an innocuous change.
It isn't that it is 4 character change. It is that matplotlib is so big!
Remember, open source is very much about scratching your own itch. I have
plenty of my own itches to scratch, so unless someone else has the same
itch as yours, you should expect to shepard your patch through.
As for the docs, perhaps that should be clarified. Your change is small, at
first, but it is incomplete. When completed, it is something that should
be a PR.
Why not use imshow() for this? Is your grid irregular?
Cheers!
Ben Root
2sn commentedon Oct 14, 2012
"""
example
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import bivariate_normal
def test():
N = 1000
x = np.exp(np.linspace(-2.0, 3.0, N))
y = np.exp(np.linspace(-2.0, 2.0, N))
100._bivariate_normal(X1, Y1, 1.0, 1.0, 0.23, 0.72)
ZG = bivariate_normal(X1, Y1, 0.1, 0.2, 2.27, 0.11) +
100._bivariate_normal(X1, Y1, 1.0, 1.0, 0.43, 0.52)
ZB = bivariate_normal(X1, Y1, 0.1, 0.2, 0.27, 2.11) +
100._bivariate_normal(X1, Y1, 1.0, 1.0, 0.53, 0.92)
ZA = bivariate_normal(X1, Y1, 0.1, 0.2, 3.27,-1.11) +
100._bivariate_normal(X1, Y1, 1.0, 1.0, 0.23, 0.82)
On 13/10/12 21:02, Benjamin Root wrote:
2sn commentedon Oct 14, 2012
Dear Ben,
OK, I will update the documentation as well and generate a PR.
yes, I want to plot large non-uniform images.
(NonUniformImage is too slow)
Best wishes,
Alexander
PS - I did have another pull request on text alignment that came with
documentation, I think that is still pending as well. There was some
discussion on github, but here was no better solution (my assessment) on
generalizing text aliment; I plan to submit another PR that will provide
a solution for text aligned with fixed-sized markers but require 2 new
keywords to text - this is what I tried to avoid.
On 13/10/12 23:36, Benjamin Root wrote:
tacaswell commentedon Dec 20, 2013
@2sn Did a PR ever come out of this?
2sn commentedon Dec 20, 2013
Dear Tom,
sorry, it did not. It's a small change - if there is interested, I can
try based on the current version.
-Alexander
On 20/12/13 14:00, Thomas A Caswell wrote:
rabernat commentedon Feb 11, 2014
I would be interested in using this feature.
tacaswell commentedon Mar 3, 2014
@2sn I think there is interest in a PR to implement this. We are triaging for 1.4.0 now, so if you can get it in soon (with in a week) then we can try to get it in.
rabernat commentedon Mar 4, 2014
Great! The workaround I found is very clunky, so I remain interested.
On Mon, Mar 3, 2014 at 11:49 AM, Thomas A Caswell
notifications@github.comwrote:
2sn commentedon Mar 4, 2014
Dear Thomas,
thanks for the heads up.
Unfortunately I am too much overloaded with proposals and teaching this
week.
-Alexander
On 04/03/14 03:49, Thomas A Caswell wrote:
earthastronaut commentedon May 20, 2014
For what it's worth, this would be a useful feature.
2sn commentedon May 21, 2014
yes. If you are interested, I made some extended color function library
at 2sn.org/python3/color.py You can use the pcolorimage defined at the
bottom.
On 21/05/14 04:47, astrodsg wrote:
petehuang commentedon Dec 30, 2016
PR still welcome for this.
Recommend labeling with new-contributor-friendly and Difficulty: Low
Pull request fixing the long standing issue matplotlib#1317
Pull request fixing the long standing issue matplotlib#1317
efiring commentedon May 23, 2019
Closed by #8690.