[Matplotlib-users] matshow unequal element sizes

2013-06-06 Thread Michiel de Hoon
Hi all,

I am trying to draw a heatmap using matshow, which I then save as a PDF.
If I then zoom in in the PDF, I notice that different rows have different 
sizes, and different columns have different sizes. It seems that some 
rows/columns have twice the height/width as other rows/columns.
Attached is a screenshot of part of the PDF after zooming in.
Is there some way to force all rows / columns to have the same height/width?

Best,
-Michiel.
attachment: image.PNG--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matshow unequal element sizes

2013-06-06 Thread Michael Droettboom
By default (when interpolation=nearest) matplotlib is performing 
nearest neighbor interpolation on the image to the request PDF dpi 
before storing it in the file.  This results in rows and columns of 
unequal size because the ratio from the original image to the 
destination resolution is likely not integral.


You can set interpolation=none, which will pass the original image 
as-is on to the file, but then we can't control the interpolation mode 
(since there's no way to tell the PDF viewer what sort of interpolation 
to perform), so that (usually) will result in bicubic interpolation, 
which is probably not what you want.


Mike

On 06/06/2013 05:52 AM, Michiel de Hoon wrote:

Hi all,

I am trying to draw a heatmap using matshow, which I then save as a PDF.
If I then zoom in in the PDF, I notice that different rows have different 
sizes, and different columns have different sizes. It seems that some 
rows/columns have twice the height/width as other rows/columns.
Attached is a screenshot of part of the PDF after zooming in.
Is there some way to force all rows / columns to have the same height/width?

Best,
-Michiel.


--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j


___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matshow unequal element sizes

2013-06-06 Thread Michiel de Hoon
Thanks! Using pcolor indeed solved the problem. Now my rows and columns are all 
nice and even.

Best,
-Michiel.





 From: Benjamin Root ben.r...@ou.edu
To: Michael Droettboom md...@stsci.edu 
Cc: Matplotlib Users matplotlib-users@lists.sourceforge.net 
Sent: Friday, June 7, 2013 1:40 AM
Subject: Re: [Matplotlib-users] matshow unequal element sizes
 




On Thu, Jun 6, 2013 at 10:14 AM, Michael Droettboom md...@stsci.edu wrote:

By default (when interpolation=nearest) matplotlib is performing nearest 
neighbor interpolation on the image to the request PDF dpi before storing it in 
the file.  This results in rows and columns of unequal size because the ratio 
from the original image to the destination resolution is likely not integral.

You can set interpolation=none, which will pass the original
  image as-is on to the file, but then we can't control the
  interpolation mode (since there's no way to tell the PDF viewer
  what sort of interpolation to perform), so that (usually) will
  result in bicubic interpolation, which is probably not what you
  want.

Mike



From experience, it seems that pcolor() or pcolormesh() works best for pdf's 
because it saves the polygons.  You might need some tweaking to get it exactly 
right, but at least the pdf viewer won't smudge it all out.


Cheers!
Ben Root

--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matshow / imshow with date-axis

2010-03-29 Thread Atomfried

Hi,

is it possible to perform a surface plot a NxM matrix with date-axes?
Similar to plot_date for 1D-Plots. The dates are available as an N-sized (or
M-sized) array of float values.

At the moment, I am using imshow or matshow for the color plots, but the
only way I found to manipulate the axes is the 'extent' keyword argument,
which is not sufficient in this context.

Any hints?

Micha
-- 
View this message in context: 
http://old.nabble.com/matshow---imshow-with-date-axis-tp28068228p28068228.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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


Re: [Matplotlib-users] matshow / imshow with date-axis

2010-03-29 Thread Matthias Michler
On Monday 29 March 2010 13:56:51 Atomfried wrote:
 Hi,

 is it possible to perform a surface plot a NxM matrix with date-axes?
 Similar to plot_date for 1D-Plots. The dates are available as an N-sized
 (or M-sized) array of float values.

 At the moment, I am using imshow or matshow for the color plots, but the
 only way I found to manipulate the axes is the 'extent' keyword argument,
 which is not sufficient in this context.

 Any hints?

 Micha

Hi Micha,

Did you already set the date-xaxis by hand?
- for axes 'ax' using e.g.
ax.xaxis_date(tz=None)
ax.yaxis_date(tz=None)

I would hope that extent and this together yield your aim, but I'm not so 
familiar with date-axes. 

Kind regards,
Mattthias

--
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


Re: [Matplotlib-users] matshow / imshow with date-axis

2010-03-29 Thread Atomfried

Hi Matthias,

Thanks for the help. The problem is, however, that the 'extent' parameter
only manipulates the range of the (integer) values on the axis. Before
setting the *axis_date property, I need to set the axes data to arrays of
(non-equidistant) floats.

Best Regards,
Micha


Matthias Michler wrote:
 
 
 Did you already set the date-xaxis by hand?
 - for axes 'ax' using e.g.
 ax.xaxis_date(tz=None)
 ax.yaxis_date(tz=None)
 
 

-- 
View this message in context: 
http://old.nabble.com/matshow---imshow-with-date-axis-tp28068228p28070890.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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


Re: [Matplotlib-users] matshow

2009-09-18 Thread Jae-Joon Lee
On Thu, Sep 17, 2009 at 2:49 AM, Bala subramanian
bala.biophys...@gmail.com wrote:
 Friends,

 I have a matrix data and i used matshow() function to plot. The plot is
 attached.

 1) After plotting the data, i used xticks() function to change the x-axis
 tick labels from x1 to x12 ( figure attached). Similarly I want to change
 the y-axis tick labels into as A,B and C,  instead of 0,1,2 (in the attached
 figure) but when i use yticks() function as below, it dosent happen, instead
 it changes the plot.

 yticks( arange(3), ('A','B','C'))


Can you post a complete code (a simplified version that reproduces the
problem)? I have done some simple tests but it worked as expected.
Also, please report the version number of your mpl installation.


 2) I used the colormap cm.autumn to create the plot. Suppose if i want to
 generate the same plot with green,black, red combination, how should i
 specify the colors in matshow.


If none of the mpl's colormaps fits your need, you need to create your
own colormap.
Maybe the links below will be helpful.

http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps

-JJ



 Thanks in advance.
 Bala

 --
 Come build with us! The BlackBerryreg; Developer Conference in SF, CA
 is the only developer event you need to attend this year. Jumpstart your
 developing skills, take BlackBerry mobile applications to market and stay
 ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
 http://p.sf.net/sfu/devconf
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matshow

2009-09-17 Thread Bala subramanian
Friends,

I have a matrix data and i used matshow() function to plot. The plot is
attached.

1) After plotting the data, i used xticks() function to change the x-axis
tick labels from x1 to x12 ( figure attached). Similarly I want to change
the y-axis tick labels into as A,B and C,  instead of 0,1,2 (in the attached
figure) but when i use yticks() function as below, it dosent happen, instead
it changes the plot.

yticks( arange(3), ('A','B','C'))

2) I used the colormap *cm.autumn* to create the plot. Suppose if i want to
generate the same plot with green,black, red combination, how should i
specify the colors in matshow.

Thanks in advance.
Bala
attachment: test.png--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matshow?

2007-03-26 Thread Suresh Pillai
Thanks again Eric for the updated matshow().

I apologise for repeating:

Since it has been decided (has it?) that matshow will retain the feature 
that a new figure is created (with aspect ratio matching the matrix), then 
if one adds a colorbar (a typical thing to do), the matrix height is 
smaller than the colorbar, which is not visually appealing.  Also, it is 
fairly common to desire combining a matrix visualisation with other plots, 
and hence the new figure becomes an issue.

Of course, I guess one could use Axes.matshow() now to avoid the above. 
If that is to be the case, fine.

One very minor thing to note: the new matshow() is missing ticks on the 
lower x-axis.

Thanks again for the excellent support for a function that clearly a lot 
of people are using.

Cheers,
Suresh


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matshow?

2007-03-19 Thread Eric Firing
Fernando Perez wrote:
[...]
 Frankly, I don't care how it's done: I wrote matshow long ago, back
 when axis('scaled') didn't exist in the first place.  If the same
 result can be achieved by other means that are cleaner, I'm sure John
 will accept a patch.

One of the matshow anomalies is that it is a pylab function only instead 
of a wrapper for an Axes method, so I made a new Axes.matshow(), and a 
temporary matshow1() pylab function that calls it.  Differences between 
matshow() and matshow1():

1) The latter labels the *centers* of the squares representing the 
matrix elements, starting from zero.  Tick values are consequently integers.

2) matshow1 uses the same function as matshow (figaspect()) to determine 
the window dimensions, but keeps the matrix elements square when they 
would be stretched in matshow.  I can change this back to the matshow 
behavior if desired.

 
 All I need regularly in my work is the ability to plot a matrix such
 that both the axis AND the enclosing figure (which determines the size
 of the resulting EPS files for publications or talks) have the aspect
 ratio of the actual matrix.  How that result is achieved is really
 immaterial to me.

I suspect that what you would actually prefer is better automated figure 
sizing so that it would always nicely enclose the axes with their 
labels, titles, etc., correct?  There is nothing magic about having the 
actual aspect ratio of the figure exactly match that of the axes box?
(Not that I can easily achieve the nice wrapping result--this is just to 
clarify the ideal.)

 
 matshow does what I need so I use it, but I have no particular
 attachment to the code other than the fact that it happens to work
 correctly.  That's a bonus in my book.

Absolutely!

Another anomaly of matshow (presently preserved in matshow1) is the 
returnall kwarg; this seems like the sort of thing that should either be 
supported by all pylab functions, or by none.  The argument for none is 
that one can easily use gcf() and gca() to get the other two arguments. 
  Do you want to keep the returnall kwarg?

Eric

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matshow?

2007-03-16 Thread Bill Baxter
Why does pylab.matshow() create a new figure by default when no other
standard pylab function I know of does that?  It seems very
inconsistent for no particular gain, since as always
figure();matshow(m) will achieve that result if that is what is
desired.

--bb

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matshow?

2007-03-16 Thread Bill Baxter
On 3/17/07, Bill Baxter [EMAIL PROTECTED] wrote:

A pox on matplotlib's default reply-to-sender!
Resending my reply that went to Fernando alone below.

 On 3/17/07, Fernando Perez [EMAIL PROTECTED] wrote:
  On 3/16/07, Bill Baxter [EMAIL PROTECTED] wrote:
   Why does pylab.matshow() create a new figure by default when no other
   standard pylab function I know of does that?  It seems very
   inconsistent for no particular gain, since as always
   figure();matshow(m) will achieve that result if that is what is
   desired.
 
  No: matshow has to create a figure with a non-standard size so that
  the final figure has the same aspect ratio as the array being
  displayed.  If you call figure() first, the figure has already been
  created.
 
  The code:
 
  # Extract actual aspect ratio of array and make appropriately sized 
  figure
  w,h = figaspect(arr)
  fig = figure(fignum,figsize=(w,h))


I guess that makes sense.
Personally I'd rather have consistency.  I'm not sure why matshow() in
particular needs to have the window shape match the image shape.

Why not just do axis('scaled') within the confines of the window you have?
Tried it out, it seems to work pretty well, and seems more consistent
with the way other things work in pylab.

def mymatshow(*args,**kw):
   Display an array as a matrix in a new figure window.
   The origin is set at the upper left hand corner and rows (first dimension
   of the array) are displayed horizontally.  The aspect ratio of the figure
   window is that of the array, as long as it is possible to fit it within
   your screen with no stretching.  If the window dimensions can't accomodate
   this (extremely tall/wide arrays), some stretching will inevitably occur.
   Tick labels for the xaxis are placed on top by default.
   matshow() calls imshow() with args and **kwargs, but by default it sets
   interpolation='nearest' (unless you override it).  All other arguments and
   keywords are passed to imshow(), so see its docstring for further details.
   Special keyword arguments which are NOT passed to imshow():
 - fignum(None): by default, matshow() creates a new figure window with
 automatic numbering.  If fignum is given as an integer, the created
 figure will use this figure number.  Because of how matshow() tries to
 set the figure aspect ratio to be the one of the array, if you provide
 the number of an already existing figure, strange things may happen.
 - returnall(False): by default, the return value is a figure instance.
 With 'returnall=True', a (figure, axes, image) tuple is returned.
   Example usage:
   def samplemat(dims):
   aa = zeros(dims)
   for i in range(min(dims)):
   aa[i,i] = i
   return aa
   dimlist = [(12,12),(128,64),(64,512),(2048,256)]
   for d in dimlist:
   fig, ax, im = matshow(samplemat(d))
   show()
   
   # Preprocess args for our purposes
   arr = asarray(args[0])

   # Extract unique keywords we can't pass to imshow
   kw = kw.copy()
   fignum = popd(kw,'fignum',None)
   retall = popd(kw,'returnall',False)

   # Extract actual aspect ratio of array and make appropriately sized figure
   w,h = figaspect(arr)
   #fig = figure(fignum,figsize=(w,h))
   fig = gcf()
   cla()
   ax  = fig.add_axes([0.15, 0.09, 0.775, 0.775])
   axis('scaled')

   ax.xaxis.tick_top()
   ax.title.set_y(1.05) # raise it up a bit for tick top
   kw['aspect'] = 'auto'
   # imshow call: use 'lower' origin (we'll flip axes later)
   kw['origin'] = 'lower'
   # Unless overridden, don't interpolate
   kw.setdefault('interpolation','nearest')
   # All other keywords go through to imshow.
   im = ax.imshow(*args,**kw)
   gci._current = im
   # set the x and y lim to equal the matrix dims
   nr,nc = arr.shape[:2]
   ax.set_xlim((0,nc))
   ax.set_ylim((nr,0))
   draw_if_interactive()
   if retall:
   return fig, ax, im
   else:
   return fig




--bb

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users