Re: [Matplotlib-users] Dark or inverted color scheme

2012-06-05 Thread David Smith
I got pretty good results with the code below.  Note that I am reading the
FLIP_COLORS from a gui checkbox.

   FLIP_COLORS = self.dark_background_flag.get()
if FLIP_COLORS:
matplotlib.rcParams['figure.facecolor'] = '0.0'
matplotlib.rcParams['axes.edgecolor'] = 'grey'
matplotlib.rcParams['text.color'] = 'white'
matplotlib.rcParams['ytick.color'] = '#00ff00'
matplotlib.rcParams['xtick.color'] = '#0ED5D5'
matplotlib.rcParams['axes.labelcolor'] = '#0ED5D5'
matplotlib.rcParams['axes.facecolor'] = 'black'
matplotlib.rcParams['grid.color'] = '0.3'
matplotlib.rcParams['grid.linestyle'] = '-'
matplotlib.rcParams['lines.markeredgewidth'] = 0.0
else:
matplotlib.rcdefaults()

## I seems like setting matplotlib.rcParams['figure.facecolor']
isn't
## enough.  I think this is a bug and set_facecolor() is a
work-around.
fig.set_facecolor(matplotlib.rcParams['figure.facecolor'])

This will flip and also flip back.  I found a few colors didn't follow
the crowd.  For example, axes.ylabel.color doesn't seem to have
an entry in rcParams.  For this, I have to modify the plot generation
statments something like:

   ax.set_ylabel('Voltage (volts)',
color=matplotlib.rcParams['ytick.color'])

That sets the ylabel text to be the same as the tick marks.  I also have to
do things like that to change line colors and such when
going flipping colors.

DavidS
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to do million data-point plots with Matplotlib?

2011-12-16 Thread David Smith
I have experimented with path.simplify and can't see any appreciable
improvements.

Incidently, I also experimented with other back ends.  I found that all the
back ends
involving Agg behave similarly.  However, using the 'GTK' backend it
renders the
whole 1 million points and does it very fast (about 5x faster than Agg
backends).

I also found that gnuplot can render the whole million points very fast
using the
'x11' terminal.  I am guessing that both matplotlib's GTK backend and
gnuplot's
'x11' terminal use the hardware accelerated display driver.

David
--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to do million data-point plots with Matplotlib?

2011-12-10 Thread David Smith
I have been working on a program that uses Matplotlib to plot data
consisting of around one million points.  Sometimes the plots succeed but
often I get an exception: OverFlowError: Agg rendering complexity exceeded.

I can make this message go away by plotting the data in chunks as
illustrated in the demo code below.  However, the extra code is a chore
which I don't think should be necessary - I hope the developers will
be able to fix this issue sometime soon.  I know that the development
version has some modifications to addressing this issue.  I wonder if it is
expected to make the problem go away?

By the way, this plot takes about 30 seconds to render on my I7 2600k.
The main program reaches the show() statement quickly and prints
Done plotting?.   Then I see that the program reaches 100% usage
on one CPU core (4 real, 8 virtual on the 2600k) until the plot is
displayed.  I wonder if there is any way to persuade Matplotlib to run
some of the chunks in parallel so as to use more CPU cores?

Plotting something other than random data, the plots run faster and
the maximum chunk size is smaller.  The maximum chunk size
also depends on the plot size - it is smaller for larger plots.  I am
wondering if I could use this to plot course and fine versions of the
plots.  The course plot is zoomed in version of the small-sized raster.
That would be better than decimation as all the points would at least
be there.

Thanks in advance,

David

--- start code -
## Demo program shows how to chunk plots to avoid the exception:
##
##    OverflowError: Agg rendering complexity exceeded.
##    Consider downsampling or decimating your data.
##
## David Smith December 2011.

from pylab import *
import numpy as np

nPts=600100
x = np.random.rand(nPts)
y = np.random.rand(nPts)

## This seems to always succeed if Npts = 2, but fails
## for Npts  3.  For points between, it sometimes succeeds
## and sometimes fails.
figure(1)
plot (x, y)

## Chunking the plot alway succeeds.
figure(2)
chunk_size=2
iStarts=range(x.size/chunk_size)
for iStart in iStarts:
    print Plotting chunk starting at %d\n % iStart
    plot(x[iStart:iStart+chunk_size], y[iStart:iStart+chunk_size], '-b')

left_overs = nPts % chunk_size
if left_overs  0:
    print Leftovers %d points\n % left_overs
    plot(x[-left_overs-1:], y[-left_overs-1:], '-r')

print done plotting?
show()
-- end code 
Please don't reply to this post It is rediculous to plot 1 million points on
screen.  I am routinely capturing million-point traces from oscilloscopes and
other test equipment and to I need to be able to spot features in the
data (glitches if you will) that may not show up plotting decimated data.
I can then zoom the plot to inspect these features.

--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Cursor corruption with pyqt4 and a work-around.

2010-06-17 Thread David Smith
I have been developing an application using PyQt ant Matplotlib and encountered
a problem with the mouse cursor shape being incorrect.  I found a work-around
that seems to work, but I think this is a bug and the fix needs to go into the
Matplotlib code base. Here are details.

My application has a central widget used fo r a Matplotlib Figure.
 Additionally there is a menu bar, button bar and two dock panels with
 controls for the plot.  I see the following behavior for the cursor:

* On start up, the cursor acts normally on startup provided
  the mouse cursor is not inside the figure widget on start-up.

* Mouse pointer shapes are set by Windows (in this case VISTA)
  and change shape according to location.  For example, touching
  the application window's border results in the arrow pointer
  changing shape to a double-headed arrow indicating the border
  can be dragged to adjust the size of the window.

* Once the mouse pointer touches the Matplotlib figure widget
  in any way, the mouse pointer will cease to show the double-arrow
  shape on the window borders - the pointer remains an arrowhead.
  You can still resize the window and the cursor does change to
  a double-arrow when you press the left button.

My workaround for this was to add the following lines of code in my
application:

def onleave(self):
   QtGui.QApplication.restoreOverrideCursor()

self.fig.canvas.mpl_connect('figure_leave_event',  onleave)

I guessed these lines by studying the matplotlib code.  Probably they
need to go somewhere inside the Matplotlib class definitions.

I hope this helps developers to correct this problem.  My application
code is medium-large and I didn't try to build a smaller example.  The
mysterious 3-line workaround solves my problem for the moment.
Perhaps it will help another PyQt and Matplotlib user and perhaps
urge developers to fix the problem in the Matplotlib core.

David Smith

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Contour with locator=FixedLocator(...) drops first and last contours from the list.

2010-03-16 Thread David Smith
Eric,
   Thank you, thank you, thank you.  This not only fixes the problem I
reported with with
FixedLocator(..) but also another one where I was using MultipleLocator(..)
and getting
the same problem issue with dropping first and last contours.  The later
isn't as easy
to work-around but your change fixed it.

David Smith

On Sat, Mar 13, 2010 at 12:30 PM, Eric Firing efir...@hawaii.edu wrote:

 David Smith wrote:

 This is a bug report.

 I am using matplotlib 0.99.1 on Windows.  When using contour with the
 keyword
 argument locator=ticker.FixedLocator(levels), the plot is always dropping
 the first
 and last contour level.  If there are less than 3 levels, contour.py
 throws an
 exception.

 My workaround is to duplicate the first and last levels when using the
 fixed locator: e.g. my argument becomes

 locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )

 I have traced the problem to the last line in contour.py, method
 _autolev() which
 strips the first and last levels if the contours are not filled:

  return lev[1:-1]

 This line occurs at line 682 in my version of contour.py which came with
 the 0.991 installation.

 I realize that I could specify the levels in the argument V and this does
 work.  However
 this code is embedded in GUI-ness which allows the user to choose how the
 contours
 are selected.  Passing the locator seems to be the best option code-wise.


 I committed a small change to svn trunk (r8190) that I think will handle
 your use case without fouling anything else up.

 Eric


 Thank you,

 Dave Smith


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Contour with locator=FixedLocator(...) drops first and last contours from the list.

2010-03-01 Thread David Smith
This is a bug report.

I am using matplotlib 0.99.1 on Windows.  When using contour with the
keyword
argument locator=ticker.FixedLocator(levels), the plot is always dropping
the first
and last contour level.  If there are less than 3 levels, contour.py throws
an
exception.

My workaround is to duplicate the first and last levels when using the fixed
locator:
e.g. my argument becomes

 locator=FixedLocator( [levels[0]] + levels + [levels[-1]] )

I have traced the problem to the last line in contour.py, method _autolev()
which
strips the first and last levels if the contours are not filled:

  return lev[1:-1]

This line occurs at line 682 in my version of contour.py which came with the
0.991 installation.

I realize that I could specify the levels in the argument V and this does
work.  However
this code is embedded in GUI-ness which allows the user to choose how the
contours
are selected.  Passing the locator seems to be the best option code-wise.

Thank you,

Dave Smith
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users