[Matplotlib-users] PS and imshow

2007-08-24 Thread Petr Danecek
Hi,
I'd like to open a high-quality image (600dpi) in matplotlib, add some
plots and save it as a postscript file. 
It seems that whatever I do, the input image gets scaled down
:-(

The same question was asked year ago. Has any progress been made since
then?
http://sourceforge.net/mailarchive/message.php?msg_id=200608311227.30594.dd55%40cornell.edu

Looking in the code of matplotlib, there is a constant of 72dpi
hardwired everywhere. For instance, backend_ps.py there is the line
self.figure.dpi.set(72) # ignore the dpi kwarg
Would rising of this value to 600 help?

No offence to developers, I did not even try to understand the code, but
using the number 72 instead of using a variable seems to be a bad
programming practice to me. 
Petr Danecek


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Vertical bar - making the bar fixed width

2007-08-24 Thread Fred Ludlow
Alen Ribic wrote:
> How do I set my vertical bar to be fixed width?

By default, bars are created with a fixed width of 0.8, which can be
changed with the width keyword arg like so:

bar(range(2), range(1,3), width = 0.5)


> Depending on amount of data on my x axis, the bars get created
> accordingly and the width gets adjusted to fit into the graph.
The width in pixels/proportion of axis is dependent on the range of the
x-axis, which you can set manually too.

There's probably a more elegant way of doing this, but here's a quick 
and dirty method for interactive mode (ipython/pylab):

# Make a figure, catch the reference as f
f = figure(1)

# Draw some bars
bar_list = bar(array([0,0.5,1.0]), array([1.0,2.0,3.0]), width = 0.25)

# Get the subplot (f.axes is a list containing the subplots)
s = f.axes[0]

# Set the x-axis limits of the subplot
s.set_xlim((-5.0, 5.0))

# Redraw
draw()


Fred

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Looking for a way to save a graph

2007-08-24 Thread David Tremouilles
OK I see... nothing straightforward...

Best way for me is maybe to implement such a system myself:
The system would collect the information to be saved by kind of
introspection of the figure.
I'm planning to save data and plot properties in an hdf5 file. Kind of
inverted process will be used to restore the figure.
Of course I will not cover the whole possible figure case but only
what I'm currently using for my work.
If somebody did similar work and is eager to share or
if somebody have any suggestion please let me know.

Thanks for the great matplotlib and to its community !

Regards,

David

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Vertical bar - making the bar fixed width

2007-08-24 Thread Alen Ribic
Thanks Fred.

Thant did the trick. However now, when I have many plots on x axis,
the last few plot shoot of the end of the x axis. It seems to start
the plotting the middle move to the right. Do I just have to adjust
the xlim on the axes[0]? I fiddled with the "align" parameter, set it
to "center", on the bar function and it didn't do much.

-Alen

>
> On 8/24/07, Fred Ludlow <[EMAIL PROTECTED]> wrote:
> > Alen Ribic wrote:
> > > How do I set my vertical bar to be fixed width?
> >
> > By default, bars are created with a fixed width of 0.8, which can be
> > changed with the width keyword arg like so:
> >
> > bar(range(2), range(1,3), width = 0.5)
> >
> >
> > > Depending on amount of data on my x axis, the bars get created
> > > accordingly and the width gets adjusted to fit into the graph.
> > The width in pixels/proportion of axis is dependent on the range of the
> > x-axis, which you can set manually too.
> >
> > There's probably a more elegant way of doing this, but here's a quick
> > and dirty method for interactive mode (ipython/pylab):
> >
> > # Make a figure, catch the reference as f
> > f = figure(1)
> >
> > # Draw some bars
> > bar_list = bar(array([0,0.5,1.0]), array([1.0,2.0,3.0]), width = 0.25)
> >
> > # Get the subplot (f.axes is a list containing the subplots)
> > s = f.axes[0]
> >
> > # Set the x-axis limits of the subplot
> > s.set_xlim((-5.0, 5.0))
> >
> > # Redraw
> > draw()
> >
> >
> > Fred
> >
> > -
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems?  Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >>  http://get.splunk.com/
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] reversing the y axis

2007-08-24 Thread Emre Aydın
hi. i'm a new user of matplotlib. i've searched through the arhieves
of the mailing list but couldn't find a quick solution. i simply need
to reverse the y axis of my plots. for example in a range of 0-10, 0
must seem at the top of the plot where 10 is lowest, near to the x
axis. is there a quick solution for this. (x axis must stay as it is)

thanx...

-- 
EMRE AYDIN
[EMAIL PROTECTED]

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Vertical bar - making the bar fixed width

2007-08-24 Thread Fred Ludlow
Alen Ribic wrote:
> Thanks Fred.
> 
> Thant did the trick. However now, when I have many plots on x axis,
> the last few plot shoot of the end of the x axis. It seems to start
> the plotting the middle move to the right. Do I just have to adjust
> the xlim on the axes[0]? I fiddled with the "align" parameter, set it
> to "center", on the bar function and it didn't do much.
> 
> -Alen

Hi Alen,

The align parameter sets whether the left, or the center of the bar 
should be aligned with the x-value you give for that bar. So the right 
hand edge of the bar would be at x+width (or x + (width/2) for center), 
and you'd need to set x_lim to include this. If I've misunderstood your 
problem can you post the code that's causing trouble?


Cheers,

Fred

ps.
gca() also gets the current axes object, which is marginally less typing 
than what I said before, so you can use:

gca().set_xlim([0.0, 10.0])
draw()

to re-scale the x-axis on the last thing you plotted to 0.0-10.0.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] reversing the y axis

2007-08-24 Thread John Hunter
On 8/24/07, Emre Aydın <[EMAIL PROTECTED]> wrote:
> hi. i'm a new user of matplotlib. i've searched through the arhieves
> of the mailing list but couldn't find a quick solution. i simply need
> to reverse the y axis of my plots. for example in a range of 0-10, 0
> must seem at the top of the plot where 10 is lowest, near to the x
> axis. is there a quick solution for this. (x axis must stay as it is)

ylim(10, 0)

JDH
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] reversing the y axis

2007-08-24 Thread Fred Ludlow
# Get min and max from current axes
y_min, y_max = gca().get_ylim()

# Set the other way round for current axes
gca().set_ylim(y_max, y_min)

# Redraw
draw()


Emre Ayd?n wrote:
> hi. i'm a new user of matplotlib. i've searched through the arhieves
> of the mailing list but couldn't find a quick solution. i simply need
> to reverse the y axis of my plots. for example in a range of 0-10, 0
> must seem at the top of the plot where 10 is lowest, near to the x
> axis. is there a quick solution for this. (x axis must stay as it is)
> 
> thanx...
> 



-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] reversing the y axis

2007-08-24 Thread Emre Aydın
On 8/24/07, Fred Ludlow <[EMAIL PROTECTED]> wrote:
> # Get min and max from current axes
> y_min, y_max = gca().get_ylim()
>
> # Set the other way round for current axes
> gca().set_ylim(y_max, y_min)
>
> # Redraw
> draw()
>
>
> Emre Ayd?n wrote:
> > hi. i'm a new user of matplotlib. i've searched through the arhieves
> > of the mailing list but couldn't find a quick solution. i simply need
> > to reverse the y axis of my plots. for example in a range of 0-10, 0
> > must seem at the top of the plot where 10 is lowest, near to the x
> > axis. is there a quick solution for this. (x axis must stay as it is)
> >
> > thanx...
> >
>
>
>
> -
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


thnx alot! that solved it...


-- 
EMRE AYDIN
[EMAIL PROTECTED]

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread Christopher Barker
Petr Danecek wrote:
> Hi,
> I'd like to open a high-quality image (600dpi) in matplotlib, add some
> plots and save it as a postscript file. 
> It seems that whatever I do, the input image gets scaled down
> :-(

I'm sorry I don't know enough about MPL's handling of images to help, but...

> Looking in the code of matplotlib, there is a constant of 72dpi
> hardwired everywhere. For instance, backend_ps.py there is the line
>   self.figure.dpi.set(72) # ignore the dpi kwarg

This may not be what it seems. The native coordinate system for 
PostScript is in points, which are 1/72 if an inch, so it's common to 
force that as a dpi. Postscript supports fractional (is it floating 
point or fixed -- I'm not sure) points, however, so you can define 
things in higher resolution, and I'm pretty sure you can imbed an 
arbitrary dpi image in a a PostScript file, using the 72dpi to positions 
the image.

The problem comes if the code, in addition to using 72dpi, also assumes 
integer coordinates, then you can't get better accuracy that 72dpi, 
which is not very good, and is really bad if someone scales it up later. 
wxWidgets addresses this by hard-coding 720dpi, rather than 72, and 
dividing by ten when writing the postscript -- still a bit of kludge. 
I'm not sure what MPL does.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread John Hunter
On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> wrote:

> This may not be what it seems. The native coordinate system for
> PostScript is in points, which are 1/72 if an inch, so it's common to
> force that as a dpi. Postscript supports fractional (is it floating
> point or fixed -- I'm not sure) points, however, so you can define
> things in higher resolution, and I'm pretty sure you can imbed an
> arbitrary dpi image in a a PostScript file, using the 72dpi to positions
> the image.

Yes, this is exactly right and the reason we do it this way.  We
support fractional points so indeed you have higher resolutions.  Off
the top of my head, I am not sure what is going on with the image
resolution problem

JDH

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Looking for a way to save a graph

2007-08-24 Thread Fernando Perez
On 8/24/07, David Tremouilles <[EMAIL PROTECTED]> wrote:
> OK I see... nothing straightforward...
>
> Best way for me is maybe to implement such a system myself:
> The system would collect the information to be saved by kind of
> introspection of the figure.
> I'm planning to save data and plot properties in an hdf5 file. Kind of
> inverted process will be used to restore the figure.
> Of course I will not cover the whole possible figure case but only
> what I'm currently using for my work.
> If somebody did similar work and is eager to share or
> if somebody have any suggestion please let me know.

A huge +1 for this approach.  Pickle is NOT meant to be a persistent,
on-disk file format, but rather a way to serialize the *current* state
of an object in memory.  Emphasis on current: if you unpickle an old
pickle in an environment where the class layout of your object (or any
object the parent holds a reference to) has changed, the unpickling
fails, completely and irrecoverably.

As someone who has already had to write pickle loader functions to
salvage old pickles (because computing them had been very expensive),
I've learned my lesson.  Pickle works well as a way to quickly
dump/load data that is either made up of simple python types *only*
(since they don't change often) or for objects that you have good
reason to expect won't be changing their API while you care about the
pickles.

But pickling is NOT a 'data format', and using it as such will
inevitably lead to much pain and suffering.  HDF5 *is* a data format.
In our project we precisely went to hdf5 instead of pickling.

Cheers,

f

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] PS and imshow

2007-08-24 Thread Jouni K . Seppänen
"John Hunter" <[EMAIL PROTECTED]> writes:

> On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> wrote:
>
>> This may not be what it seems. The native coordinate system for
>> PostScript is in points, which are 1/72 if an inch, so it's common to
>> force that as a dpi. [...]
>
> Yes, this is exactly right and the reason we do it this way.  We
> support fractional points so indeed you have higher resolutions.  Off
> the top of my head, I am not sure what is going on with the image
> resolution problem

I just tried with current svn, and the following script produces two
results that have visibly different resolutions:

#!/usr/bin/python
from pylab import *
foo = rand(10,10)
imshow(foo)
savefig('foo10.ps', dpi=10)
savefig('foo100.ps', dpi=100)

Perhaps the original poster could show a bit of code where the scaling
fails?

(I'm not sure if figimage is doing the right thing, though...)

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Error TclError: no display name and no $DISPLAY environment variable

2007-08-24 Thread Deen Sethanandha
Hi,

  I use matplotlib as part of my Trac plugin.  I got this error when I try
to access the web site that use my plugin.  Please see the trace back below

File "/u/bhuricha/lib/python2.5/site-packages/Trac-
0.11dev_r5933-py2.5.egg/trac/web/main.py", line 381, in dispatch_request
File "/u/bhuricha/lib/python2.5/site-packages/Trac-
0.11dev_r5933-py2.5.egg/trac/web/main.py", line 191, in dispatch
File
"/u/bhuricha/source/trac-hacks/tracmetrixplugin/0.11/tracmetrixplugin/web_ui.py",
line 119, in process_request
File
"/u/bhuricha/source/trac-hacks/tracmetrixplugin/0.11/tracmetrixplugin/web_ui.py",
line 193, in _render_view
File
"/u/bhuricha/source/trac-hacks/tracmetrixplugin/0.11/tracmetrixplugin/model.py",
line 452, in get_daily_backlog_chart
File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line 876, in
figure
File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py",
line 88, in new_figure_manager
File "lib-tk/Tkinter.py", line 1639, in __init__

Local variables:
NameValue
baseName'trac.cgi'
className'Tk'
ext'.cgi'
interactive0
os
screenNameNone
selfNone
sync0
sys
useNone
useTk1

  I am not sure what's wrong.  I was able to get this to work in the
different environment.  Can anyone tell me what might be wrong?

Thanks,
Deen
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Error TclError: no display name and no $DISPLAY environment variable

2007-08-24 Thread Jouni K . Seppänen
"Deen Sethanandha" <[EMAIL PROTECTED]> writes:

>   I use matplotlib as part of my Trac plugin.  I got this error when I try
> to access the web site that use my plugin.  [...]
>
> File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line 876, in
> figure
> File
> "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py",
> line 88, in new_figure_manager
> File "lib-tk/Tkinter.py", line 1639, in __init__

Your plugin is importing pylab, which automatically imports the TkAgg
backend based on your .matplotlibrc setting, and this makes no sense 
in a non-interactive environment. The quick way to make this work is 
to replace "import pylab" by the following lines:

import matplotlib
matplotlib.use('Agg')
import pylab

See also: examples/webapp_demo.py.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users