Re: [Matplotlib-users] Add some explanatory text to the legend

2012-01-25 Thread Ethan Swint


On 1/25/2012 1:32 PM, Neal Becker wrote:
> I have a legend that is going to have some abbreviations to compactly indicate
> the properties of different lines in a graph.  I'd like to add a little 'key' 
> to
> explain what the notation means.  Any suggestion?
I was thinking of the annotate functionality, but on second thought, I 
think you are looking for something like
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.text

Regards,
Ethan

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Ethan Swint


On 1/23/2012 1:55 PM, Russ Dill wrote:
> On Mon, Jan 23, 2012 at 11:17 AM, Stan West  wrote:
>>> From: Russ Dill [mailto:russ.d...@gmail.com]
>>> Sent: Saturday, January 21, 2012 16:31
>>>
>>> I'm using matplotlib from pylab to generate eye patterns for signal
>>> simulations.
>> ...
>>
>>> Is there any way within matplotlib to do that right now?
>> One way combines Numpy's histogram2d and matplotlib's imshow, as in the
>> example in the histogram2d docs [1].  The example's x array should become all
>> of the time samples in your traces, strung together in one dimension; the y
>> array, the corresponding voltage samples.
>>
> I'll try it out and see what I get, but I don't think it will work so
> well. The problem is that while the data is made up of x/y samples, it
> actually represents a line. The samples should be evenly distributed
> not along the x or y axis, but along the length of the line. I feel
> like I'll need a line drawing algorithm.
>
> (For example, if samples are evenly distributed along the x axis, a 89
> degree line is highly under-represented, but a 1 degree line is highly
> over-represented. The number of samples should be sqrt(dx^2 + dy^2),
> but with evenly spaced x samples, its just dx.

I don't know of a way to directly produce the LeCroy heatmap in Python, 
so here's my idea for a hack:
*Each sample point you have from the trace represents a point in XY 
coordinates.
*Similarly, the plot area is filled with regularly spaced XY coordinates.
*Every trace sample will fall within a square bounding box with four points.
*Each plot area point gets a membership value, based on distance between 
centers of the sample point and the plot area point.
*To construct the heat diagram, sum the membership values of all sample 
points for all traces.
*Display it with a contour plot, but without the isovalue lines.

-Ethan

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MQMQ: How to adjust the size and scale of the x-y axis of the graph.Thanks.

2012-01-23 Thread Ethan Swint
On 1/20/2012 5:31 PM, MQMQ wrote:
> Dear all,
>
> Could you guys share your experience on:
> How to adjust the size and scale of the x-y axis of the plot (e.g. how to
> resize the "0 1 2" on x axis ), Thanks?
> And special commands in matplotlib?
>
> Thank you so much in advanced.
> MQMQ
You can change the font sizes for most of the plotting elements with the 
pyplot variable pyplot.rcParams.
Change the range of the XY axes by calling
pypolt.xlim(0,360)
pyplot.ylim(-0.01,4.05)
-or-
pyplot.axis(0,360,-0.01,4.05)
and you can adjust the ticmark values by
pyplot.xticks(range(360))

Also look into the pyplot.setp method.

-Ethan


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlabel cut off in the example embeding_in_qt4.py

2012-01-21 Thread Ethan Swint
On 1/21/2012 9:12 PM, Forest Yang wrote:
> Hi,
>
> I am embedding a plot in Qt4 application, following the matplotlib
> example embeding_in_qt4.py, however I found that the xlabel is cut
> off, although the label shows more if I resize the window, still it is
> not the right one. Is it because of my local parameter settings or
> it's the limit of the example code. How can I fix this ?
>
>Thanks.
>
> Best regards,
> Forest Yang

I dashed that last reply off quickly - a more complete answer would 
address your local parameter settings.  In pyplot.rcParams, you can set 
the default values for a number of parameters. In this case, I believe 
the parameters that will affect the cropping are the image size and the 
sizes of the axis labels and tics. I'm fairly new to these items myself 
- I'm not convinced that changes rcParams will be preserved from one 
python session to the next.

-Ethan

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlabel cut off in the example embeding_in_qt4.py

2012-01-21 Thread Ethan Swint


On 1/21/2012 9:12 PM, Forest Yang wrote:
> Hi,
>
> I am embedding a plot in Qt4 application, following the matplotlib
> example embeding_in_qt4.py, however I found that the xlabel is cut
> off, although the label shows more if I resize the window, still it is
> not the right one. Is it because of my local parameter settings or
> it's the limit of the example code. How can I fix this ?
>
>Thanks.
>
> Best regards,
> Forest Yang
Take a look into pyplot.subplots_adjust - you can specify buffers there 
as a fraction of the window size, e.g.
pyplot.subplots_adjust(0.155,0.12,0.95,0.9) works well for a 3.5"x3" 
figure with 8-pt font on the axis labels and tics.

-Ethan

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to tell savefig() image size in pixels

2012-01-17 Thread Ethan Swint

It's a bit of a pain:

xPix = 900
yPix = 600

xSize = 3 #inches
ySize = xSize/xPix*yPix
gcf().set_inches_size(xSize,ySize)
gcf().savefig('test.png',dpi=xSize/xPix)

You can also chance pyplot.rcParams - it's a dictionary of default values.

On 1/17/2012 12:10 PM, Keith Hughitt wrote:
I'd also be interested if anyone has a suggestion for how to save a 
figure such that the pixel dimensions of a subplot (e.g. an image) are 
set.


On Sat, Jan 14, 2012 at 8:57 AM, klo uo > wrote:


I browsed Google, and found mainly outdated code examples (also on
scipy cookbook) then some 2008 posts on StackOverflow where at
least I find some trace that matplotlib.figure.Figure has some
instruments to change output image size, but it's in combination
from inches and dpi set. However I just couldn't find how to tell
my plt graph to use this matplotlib.figure.Figure settings, and
ended editing matplotlibrc file and changing inches and DPI there

Shouldn't be there some easier setting to set image size for
savefig() output?


--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d


___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Bug in griddata

2012-01-10 Thread Ethan Swint
Hi-

I was working off of the example listed at 
http://matplotlib.sourceforge.net/examples/pylab_examples/griddata_demo.html, 
adapting it to my own data, and encountered the following error on MLAB 
1.1.0, Python 2.7.2:


from numpy.random import uniform, seed
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
import numpy as np
# make up data.
#npts = int(raw_input('enter # of random points to plot:'))
seed(0)
npts = 200
x = uniform(-2,2,npts)
y = uniform(-2,2,npts)
z = x*np.exp(-x**2-y**2)
xi = np.linspace(0,60,100)  # <= my xdata range
yi = np.linspace(0,0.9,200) # <= my ydata range
zi = griddata(x,y,z,xi,yi,interp='linear')



which produces 
---
ValueErrorTraceback (most recent call last)
C:\Users\Ethan\code\PythonScripts\ in 
()
> 1 zi = griddata(x,y,z,xi,yi,interp='linear')

It seems that 'xi,yi = np.meshgrid(xi,yi)' from line 2766 of mlab.py 
doesn't always produce uniformly spaced data, as the test for uniform 
data fails at line 2779.  Ignoring the error, however, results in 
satisfactory evaluation of interp() on 2783.

Can anyone else reproduce?

Regards,
Ethan

--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] exact figure size frustration

2012-01-08 Thread Ethan Swint


On 1/8/2012 2:29 AM, Eric Firing wrote:
> On 01/07/2012 07:01 PM, Ethan Swint wrote:
>> Hi, list-
>>
>> This question has been asked before, but all of my search results don't
>> address my problem:
>> 
>> fig = figure(1, figsize=(3.25, 3))
>> plot([0,1,5,2,9])
>> title('title')
>> xlabel('xAxis')
>> ylabel('yAxis')
>> fig.savefig('test.png',dpi=600)
>> 
>> The resulting figure is 2040x1890 pixels, or 3.4"x3.15", and the xlabel
>> is cut off.  Looking at the PNG file in an image editor, it appears that
>> the axes and ticklabels fit the desired size.  I've tried taking the
>> difference from the output size and requested size and feeding that back
>> in (3.25 - (3.4-3.25) = 3.10, but matplotlib seems to add an arbitrary
>> buffer and it still doesn't come out to the desired size.  How does one
>> make an overall figure that is the desired size?
> Ethan,
>
> There seem to be two questions here.  First, when I run your code, I get
> a png file of the right size:
>test.png: PNG image data, 1950 x 1800, 8-bit/color RGBA, non-interlaced
>
> What version of mpl are you using?  I don't recall that it ever had the
> property you are reporting, generating a larger figure than requested.
>
> The second question is about the xlabel getting cut off. This is
> happening because mpl is using default subplot parameters that leave
> plenty of space for tick labels and axis labels with the default figure
> size, but don't leave enough if the figure is much smaller, and leave
> too much if the figure is much bigger.  The subplot parameters are
> expressed as fractions of the figure size, but the text does not scale
> automatically with the figure size.  Therefore you have to either
> specify the Axes position manually to leave the right size margins, or
> use subplots_adjust.  When a figure is displayed on the screen, there is
> a button on the toolbar that brings up a subplots_adjust widget; this
> can be used to find values appropriate for your figure size, which you
> can then supply to your script.  In the standard set of mpl examples
> there are many instances of subplots_adjust, e.g.,
> http://matplotlib.sourceforge.net/examples/pylab_examples/subplots_adjust.html
Eric-

Thanks for your reply.  I actually had the MPL version copied, but 
somehow I forgot to paste it:  matplotlib.__version__ is 1.0.1 on Python 
2.7.2, Ipython v. 0.11, on Windoze 7 x64.  Around 2AM I found that if I 
called fig.set_size_inches(3.25,3) just before calling fig.savefig(), it 
did produce the proper size image.
For your viewing pleasure, on my system I get:

In [228]: fig = figure(3, figsize=(3.15, 3.15))
In [229]: fig.savefig('test0.png',dpi=600)
In [230]: fig.get_size_inches()
Out[230]: array([ 3.3,  3.3])
<\code>
The output is indeed 3.3"x3.3" (1980x1980).  I'll upgrade to MPL 1.1.0 
and see if that helps the initial size problem.
As for subplots_adjust - I'll have to dig into that.  Will I need to 
make my figure with subplot(111) instead of figure()?  Hmm - off to 
experiment.

Thanks,
Ethan

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] exact figure size frustration

2012-01-07 Thread Ethan Swint
Hi, list-

This question has been asked before, but all of my search results don't 
address my problem:

fig = figure(1, figsize=(3.25, 3))
plot([0,1,5,2,9])
title('title')
xlabel('xAxis')
ylabel('yAxis')
fig.savefig('test.png',dpi=600)

The resulting figure is 2040x1890 pixels, or 3.4"x3.15", and the xlabel 
is cut off.  Looking at the PNG file in an image editor, it appears that 
the axes and ticklabels fit the desired size.  I've tried taking the 
difference from the output size and requested size and feeding that back 
in (3.25 - (3.4-3.25) = 3.10, but matplotlib seems to add an arbitrary 
buffer and it still doesn't come out to the desired size.  How does one 
make an overall figure that is the desired size?

Thanks,
Ethan

--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Noob assist: trailing value graph

2010-08-19 Thread Ethan Swint
Aha!  I knew it must be that simple, I just yet hadn't hit on step.

Thanks,
Ethan

On 08/19/2010 09:14 PM, Ryan May wrote:
> On Thu, Aug 19, 2010 at 5:03 PM, Ethan Swint  wrote:
>
>> Hi-
>>
>> I'm trying to plot an XY line graph with discrete XY pairs in it with a
>> step response between each pair.  In other words, on the range [X1,X2),
>> it should have a horizontal line at Y1, at X2, the line goes vertical
>> from Y1 to Y2, then on the range [X2,X3), it should have a horizontal
>> line at Y2.  I haven't seen any examples yet, and my forays into the
>> documentation haven't yielded up a simple way to do this.  Is there a
>> simple option to do this, or do I have to pad my data with X1,
>> X2-epsilon, X2, X3-epsilon, etc.
>>  
> What you're looking for is the step() plotting function:
>
>step(x, y, *args, **kwargs)
>
>  Make a step plot. Additional keyword args to :func:`step` are the same
>  as those for :func:`~matplotlib.pyplot.plot`.
>
>  *x* and *y* must be 1-D sequences, and it is assumed, but not checked,
>  that *x* is uniformly increasing.
>
>  Keyword arguments:
>
>  *where*: [ 'pre' | 'post' | 'mid'  ]
>If 'pre', the interval from x[i] to x[i+1] has level y[i+1]
>
>If 'post', that interval has level y[i]
>
>If 'mid', the jumps in *y* occur half-way between the
>*x*-values.
>
> Ryan
>
>

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Noob assist: trailing value graph

2010-08-19 Thread Ethan Swint
Hi-

I'm trying to plot an XY line graph with discrete XY pairs in it with a 
step response between each pair.  In other words, on the range [X1,X2), 
it should have a horizontal line at Y1, at X2, the line goes vertical 
from Y1 to Y2, then on the range [X2,X3), it should have a horizontal 
line at Y2.  I haven't seen any examples yet, and my forays into the 
documentation haven't yielded up a simple way to do this.  Is there a 
simple option to do this, or do I have to pad my data with X1, 
X2-epsilon, X2, X3-epsilon, etc.

Thanks,
Ethan

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users