Re: [matplotlib-devel] color mix
Robert Kern <[EMAIL PROTECTED]> writes: > L*u*v* or its cylindrical-coordinate cousin L*t*theta* (or > LCH_uv). "Choosing Color Palettes for Statistical Graphics" is a > nice paper talking about an implementation in R (although they do > seem to misname L*t*theta* as HCL, which officially is different): > >http://eeyore.ucdavis.edu/stat250/epub-wu-01_abd.pdf That link did not work for me, this looks to be an alternative: http://epub.wu-wien.ac.at/dyn/virlib/wp/eng/mediate/epub-wu-01_abd.pdf?ID=epub-wu-01_abd -- Pete Forman-./\.- Disclaimer: This post is originated WesternGeco -./\.- by myself and does not represent [EMAIL PROTECTED]-./\.- the opinion of Schlumberger or http://petef.22web.net -./\.- WesternGeco. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] spy: ignore zero values in sparse matrix
When sparse matrices have explicit zero values, `axes.spy` plots those
zero values. This behavior seems unintentional. For example, the
following code should have a main diagonal with markers missing in the
middle, but `spy` currently plots a full main diagonal.
#~~~
import scipy.sparse as sparse
import matplotlib.pyplot as plt
sp = sparse.spdiags([[1,1,1,0,0,0,1,1,1]], [0], 9, 9)
plt.spy(sp, marker='.')
#~~~
Below is a patch which only plots the nonzero entries in a sparse
matrix. Note, sparse matrices with all zero entries raises an error;
this behavior differs from dense matrices. I could change this
behavior, but I wanted to minimize the code changed.
Cheers,
-Tony
PS: this patch also includes two trivial changes to some examples.
Index: lib/matplotlib/axes.py
===
--- lib/matplotlib/axes.py (revision 6122)
+++ lib/matplotlib/axes.py (working copy)
@@ -6723,9 +6723,11 @@
else:
if hasattr(Z, 'tocoo'):
c = Z.tocoo()
-y = c.row
-x = c.col
-z = c.data
+nonzero = c.data != 0.
+if all(nonzero == False):
+raise ValueError('spy cannot plot sparse zeros
matrix')
+y = c.row[nonzero]
+x = c.col[nonzero]
else:
Z = np.asarray(Z)
if precision is None: mask = Z!=0.
Index: examples/pylab_examples/masked_demo.py
===
--- examples/pylab_examples/masked_demo.py (revision 6122)
+++ examples/pylab_examples/masked_demo.py (working copy)
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python
'''
Plot lines with points masked out.
Index: examples/misc/rec_groupby_demo.py
===
--- examples/misc/rec_groupby_demo.py (revision 6122)
+++ examples/misc/rec_groupby_demo.py (working copy)
@@ -2,7 +2,7 @@
import matplotlib.mlab as mlab
-r = mlab.csv2rec('data/aapl.csv')
+r = mlab.csv2rec('../data/aapl.csv')
r.sort()
def daily_return(prices):
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] spy: ignore zero values in sparse matrix
On Fri, Sep 26, 2008 at 12:39 PM, Tony S Yu <[EMAIL PROTECTED]> wrote:
> +if all(nonzero == False):
> +raise ValueError('spy cannot plot sparse zeros
> matrix')
Is raising an exception the right choice here -- why can't we plot an
all zeros image?
JDH
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] spy: ignore zero values in sparse matrix
On Sep 26, 2008, at 2:28 PM, John Hunter wrote:
> On Fri, Sep 26, 2008 at 12:39 PM, Tony S Yu <[EMAIL PROTECTED]> wrote:
>
>> +if all(nonzero == False):
>> +raise ValueError('spy cannot plot sparse zeros
>> matrix')
>
> Is raising an exception the right choice here -- why can't we plot an
> all zeros image?
>
> JDH
I guess you could plot sparse all-zero matrices with image mode. My
only hesitation is that sparse arrays tend to be very large and (I
imagine) this would lead to very slow performance. I assumed this was
the reason image mode wasn't adapted to use sparse arrays.
Actually, now that I think about it: you could plot a trivially small
image and just adjust the coordinates so that they correspond to the
original matrix shape. Is this what you were thinking?
I should note that a dense zero array also fails to plot with spy *if
marker mode is used*.
-T
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] spy: ignore zero values in sparse matrix
On Sep 26, 2008, at 3:38 PM, John Hunter wrote: > On Fri, Sep 26, 2008 at 2:36 PM, Tony S Yu <[EMAIL PROTECTED]> wrote: >> >> Actually, now that I think about it: you could plot a trivially >> small image >> and just adjust the coordinates so that they correspond to the >> original >> matrix shape. Is this what you were thinking? > > This is something I considered, but I was thinking less about the > implementation and more about the functionality. I don't want to > raise an exception unless the input doesn't make sense. I would > rather the user start at a boring image and figure out why it is blank > that deal with an exception. Yeah, I agree this is much friendlier. >> I should note that a dense zero array also fails to plot with spy >> *if marker >> mode is used*. > > Can you fix this along with spy2? I assume you mean spy, not spy2 (I just searched through the matplotlib files and saw that spy2 hasn't existed since 2006). I'll work on a patch to return a blank plot using the method described above (unless someone chimes in with a better suggestion). -Tony - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] spy: ignore zero values in sparse matrix
Tony S Yu wrote:
> On Sep 26, 2008, at 2:28 PM, John Hunter wrote:
>
>> On Fri, Sep 26, 2008 at 12:39 PM, Tony S Yu <[EMAIL PROTECTED]> wrote:
>>
>>> +if all(nonzero == False):
>>> +raise ValueError('spy cannot plot sparse zeros
>>> matrix')
>> Is raising an exception the right choice here -- why can't we plot an
>> all zeros image?
>>
>> JDH
>
> I guess you could plot sparse all-zero matrices with image mode. My
> only hesitation is that sparse arrays tend to be very large and (I
> imagine) this would lead to very slow performance. I assumed this was
> the reason image mode wasn't adapted to use sparse arrays.
Also, if an image cannot be resolved by the output device, info is
lost--one might not see anything at a location where there actually is a
value--whereas with markers, a marker will always show up, and the only
problem is that one can't necessarily distinguish a single point from a
cluster.
The real problem with all-zero values is that plot can't handle
"plot([],[])". One can work around this by putting in bogus values to
plot a single point, saving the line, and then setting the line data to
empty; or, better, by not using the high-level plot command, but by
generating the Line2D object and adding it to the axes. The Line2D
initializer is happy with empty x and y sequences. I think if you use
this approach it will kill two bugs (failure on all-zeros with sparse
and full arrays) with one very simple stone.
Eric
>
> Actually, now that I think about it: you could plot a trivially small
> image and just adjust the coordinates so that they correspond to the
> original matrix shape. Is this what you were thinking?
>
> I should note that a dense zero array also fails to plot with spy *if
> marker mode is used*.
>
> -T
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Matplotlib-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
