Re: [Matplotlib-users] colors

2014-06-20 Thread Bruno Pace
Ok! I'm getting there! I've been trying to figure out, though, how to set
black - for example - for the zero values BUT interpolate also the colors
linearly from black to blue in the linear region (from zero to the linear
threshold). Is there a way to change the colormap like that?

Thanks a lot!
On 2014/06/18, 5:23 AM, Bruno Pace wrote:

> Ok, so using the norm=SymLogNorm I cannot distinguish the values that
> are exactly 0.0 from the really small ones, right? Would it be possible
>

Correct, the scale is linear for small values.

 to make use of the set_bad method without having to use masked arrays,
> just combining the SymLogNorm and the set_bad?
>

No, the mask is what identifies a point as bad.  If you want to distinguish
zero from non-zero, no matter how small, then this is the way to do it.

zm = np.ma.masked_equal(z, 0, copy=False)

Now you have a masked array where the points that are exactly zero are
masked.

The bad color won't show up on the colorbar, however.  There is no suitable
place for it.  It can show only the range from vmin to vmax, and a
"set_over" color for values greater than vmax, and a "set_under" color for
values less than vmin.

Eric
--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colors

2014-06-18 Thread Bruno Pace
Ok, so using the norm=SymLogNorm I cannot distinguish the values that are
exactly 0.0 from the really small ones, right? Would it be possible to make
use of the set_bad method without having to use masked arrays, just
combining the SymLogNorm and the set_bad?

Thanks!


2014-06-17 21:20 GMT+02:00 Eric Firing :

> On 2014/06/17, 8:59 AM, Bruno Pace wrote:
> > Hi all,
> >
> > I'm trying to use imshow to plot some values which fall on the interval
> > [0,1]. I need to
> > use a logscale to emphasize the scales of the data. The solution I found
> > checking some discussions was like this
> >
> > plt.imshow(X, interpolation='none', norm=matplotlib.colors.LogNorm())
> >
> > However, I notice that the way these colors are assigned are not always
> > the same (although my data always contains the minimum value 0.0 and
> >   the maximum 1.0). I need to have a coherent color scale to indicate
> > the real values. Is it easier to do the color code myself? What is the
> > proper way of tackling this problem??
>
> Use the vmin and vmax kwargs to LogNorm, remembering that vmin must be
> greater than zero for a log scale.
>
> Eric
>
> >
> > It's pretty much the same problem described here, but with a logscale...
> >
> >
> http://stackoverflow.com/questions/7875688/how-can-i-create-a-standard-colorbar-for-a-series-of-plots-in-python
> >
> >
> > Thank you very much!
> >
> > Bruno
> >
> >
> >
> --
> > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> > Find What Matters Most in Your Big Data with HPCC Systems
> > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> > Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> > http://p.sf.net/sfu/hpccsystems
> >
> >
> >
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
>
> --
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] animation optimization

2014-06-18 Thread Bruno Pace
Hey all,

I am trying to produce an animation from several images generated with
imshow from a sequence of arrays in time, I have done that in several ways.
However, my animations consist of several frames (on the order of 1
frames) and thus the simulation crashes when it's too large.

The solution I found was writing the png files and then animating. It is
very time and memory consuming, though, and I have the impression it is not
the best solution to tackle this problem. What is the best practice to deal
with this problem?

Thanks!

Bruno

P.S.: I'm using Ipython, would it change running from a terminal instead of
running it from the shell?
--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] colors

2014-06-17 Thread Bruno Pace
Hi all,

I'm trying to use imshow to plot some values which fall on the interval
[0,1]. I need to
use a logscale to emphasize the scales of the data. The solution I found
checking some discussions was like this

plt.imshow(X, interpolation='none', norm=matplotlib.colors.LogNorm())

However, I notice that the way these colors are assigned are not always the
same (although my data always contains the minimum value 0.0 and  the
maximum 1.0). I need to have a coherent color scale to indicate the real
values. Is it easier to do the color code myself? What is the proper way of
tackling this problem??

It's pretty much the same problem described here, but with a logscale...

http://stackoverflow.com/questions/7875688/how-can-i-create-a-standard-colorbar-for-a-series-of-plots-in-python


Thank you very much!

Bruno
--
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] dynamic plottinng

2013-09-19 Thread Bruno Pace
Hi all,

I am trying to plot the time evolution of a probability distribution, but I
don't know how to use it. I have a different histogram for each time step.
I tried plt.ion()  but I'm not sure how to use it. I'm sure it must be a
simple solution, but I haven't really found out how to do it! If I use
plt.show() as written below, I have to close the window every time for it
to reopen. Here is my code, can you help me?

import matplotlib.pyplot as plt
import numpy
import math

def p(N, Na, fa,  fb):
return float(Na)*fa/(Na*fa + (N-Na)*fb)

def binomial(n,k):
   if k > n-k:
   k = n-k
   accum = 1
   for i in range(1,k+1):
  accum *= (n - (k - i))
  accum /= i
   return accum

def pk(N, k, p):
return binomial(N, k)*math.pow(p,k)*math.pow((1-p),(N-k))

def expected(N, dist):
soma = 0
for k in range(N + 1):
soma += k*dist[k]
return soma

def drawhist(menMeans):

N = len(menMeans)

ind = numpy.arange(N)

width = 1.0

plt.clf()

plt.ylabel('Probability')
plt.xlabel('k')
plt.xlim(0.0,N)
plt.ylim(0.0,1.0)
plt.bar(ind, menMeans, width)
plt.draw()
plt.show()



N = 100
Na = 50
fa = 10
fb = 5



pks = [0]*(N+1)
pks[Na] = 1
pkst = [0]*(N+1)
expect = [Na]

drawhist(pks)
p = [p(N, n, fa, fb) for n in range(N + 1)]

for t in range(5):
for Na in range(N + 1):
for k in range(N + 1):
pkst[k] += pks[Na]*pk(N, k, p[Na])
drawhist(pkst)
pks = pkst
pkst = [0]*(N+1)
expect.append(expected(N, pks))
--
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users