Re: [Matplotlib-users] Change Hue-Range in HSV color map

2009-02-01 Thread Jouni K . Seppänen
KarlBlau mailsgetl...@web.de writes:

 I would like to change the hue range of the hsv color map to use only hue
 values between 0 and 0.6667. I checked the documentation of matplotlib and
 searched in the internet but couldn't find the answer.

There doesn't seem to be any predefined functionality for this. The
easiest way to achieve this is probably just to take the definition of
hsv from _cm.py and modify it a little:

data = {'red':   ((0., 1., 1.),(0.158730, 1.00, 1.00),
  (0.174603, 0.968750, 0.968750),(0.33, 0.031250, 0.031250),
  (0.349206, 0.00, 0.00),(0.67, 0.00, 
0.00)),
'green': ((0., 0., 0.),(0.158730, 0.937500, 0.937500),
  (0.174603, 1.00, 1.00),(0.507937, 1.00, 1.00),
  (0.67, 0.062500, 0.062500)),
'blue':  ((0., 0., 0.),(0.33, 0.00, 0.00),
  (0.349206, 0.062500, 0.062500),(0.507937, 1.00, 1.00),
  (0.67, 1.00, 1.00))}
for k,v in data.items():
data[k] = [(a/0.67, b, c) for (a,b,c) in v]
myhsv = matplotlib.colors.LinearSegmentedColormap('myhsv', data)

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


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ticks in Matplotlib

2009-02-01 Thread Eli Bressert
Hi,

I'm looking into customizing the the tick positions on an imshow plot. I 
found that you can do this by doing

img = imshow(data)
img.ax.xaxis.set_ticks([100.,200.])


The problem with this method is that it moves the tick positions on the 
bottom and top x axis. What if I wanted to do have the top axes show 
ticks at slightly different positions than the bottom one? Any ideas or 
suggestions would be greatly appreciated

-Eli

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-devel] What would you like to see in a book about Matplotlib?

2009-02-01 Thread Sandro Tosi
Hi Chris,
thanks for your reply, helpful as usual :)

On Fri, Jan 30, 2009 at 18:59, Chris Walker
chr...@chiark.greenend.org.uk wrote:
   Firstly, good luck with the book.

cheers :)

 The sort of book I'd buy would explain how to use the combination of
 matplotlib/ipython/scipy/numpy to analyse data.

Sadly, that would not the book I'll write :( The editor wanted to
target another audience for the book: experienced python developers,
with no knowledge of matplotlib; so an introductionary book, that will
show even how to integrate mpl on GTK/WX application and on the web.

I pushed to have something about science, and a chapter will be about
that, but I need your (all) inputs, because my science days are long
back in the past ;)

 - what are the (basic) things that, when you were beginning to use
 matplotlib, you wanted to see grouped up but couldn't find?
 - what would you like to see in a book about matplotlib?

 Start off by reading data from a file, plotting it and fitting a
 function to that data.

That sounds something that could land in the science chapter.

 Plotting with related scales
 

 Sometimes it is useful to plot related scales on x1 and x2 axes. I've
 come across this several times in different contexts. In its simplest
 form, there is a linear relationship between the axes. In a mechanical test, 
 you might want extension on the x1 axis and strain on the x2 axis (for 
 example).

 Sometimes there is not a linear relationship. For example you might
 want to plot frequency (or photon energy) on x1 and wavelength on x2.

 An even more complex example is a Hall-Petch plot:

 (Yield Stress) = k/sqrt(Grain Size)

 So plotting 1/Sqrt(Grain Size) on the X1 axis gives a linear
 plot, but it would be useful to plot the grain size on the X2 scale.

Err, I think I lost you ;)

What you want is 2 plots on the same figure? so not 2 Ys for the same
X (let's say X is time, and Y1 is stock price variation, and Y2 is the
percentage change), you want X1-Y1 (let's say on the bottom-left) and
X2-Y2 (on the upper-right): did I get you?

 ipython and emacs
 -

 Suppose I want to write a script to analyse some data (perhaps I want
 a record of what I've done, or perhaps I'd like to perform the same
 analysis on several data sets). I'd probably do so in emacs - but it
 is useful to do some experimentation in ipython - tab completion is
 particularly useful. I feel there must be a good way to do my
 experimentation in ipython and save the important bits in emacs - but
 I've not sat down and worked out an efficient way of doing this.

I think the preferred way to do so it using ipython, and for now I
plan only to show it on the book.

 Data aqcuisition and experimental control:
 -

 Writing a simple application to acquire data - ideally from multiple
 sources and plot the data as it is acquired. In my case I wanted to
 combine mechanical with electrical tests. A couple of interesting
 articles by G Varoquaux are listed at
 http://wiki.debian.org/DebianScience/DataAcquisition

 This is perhaps beyond the scope of the book, but it has come up on
 the mailing lists a couple of times. The ideal application would have
 a gui for simple use, but a command line (probably ipython) for more
 more complex use - perhaps performing a series of tests under
 different conditions.

I thought about an example for this already! :) I thought to develop a
sample application for GTK/WX that display some system value (like cpu
usage or so, in this way everyone can run the example) plotting the
information as it comes (for 30 secs, for example).

 Some discussion of plotting non gridded 2d data should also be in
 there.

for example?

 Your suggestions are really appreciated :) And wish me good luck!

 I don't think it is the thrust of your book, but another book I was
 looking for is A cookbook of Numerical simulations of classic
 physics/engineering problems. For use by physicists/engineers who
 don't want to rewrite things from scratch.

As said, even if my degree is in linear algebra, my science days are
gone, so it won't be in the book, if not for that chapter about
science and mpl.

 Good luck.

Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ticks in Matplotlib

2009-02-01 Thread Jae-Joon Lee
You cannot set different tick positions for bottom and top x-axis in
the same axes.
What you can do is to make another axes at the same location and use
it to draw ticks at top.
Take a look at

http://matplotlib.sourceforge.net/examples/api/two_scales.html

But it may not be an ideal solution for you as this enforces
adjustable=datalim.

You may try to use my custom axes class.

http://dl.getdropbox.com/u/178748/mpl/parasite_axes2.py

import matplotlib.pyplot as plt
import numpy as np

from parasite_axes2 import SubplotHost

fig = plt.gcf()
ax = SubplotHost(fig, 1, 1, 1)
fig.add_subplot(ax)
Z = np.arange(100).reshape(10,10)
im = ax.imshow(Z)

ax2 = ax.twin()

ax2.set_xticks([0, 3, 6, 9])
ax2.set_yticks([1,3,5,7,9])

plt.draw()
plt.show()


Note that it enforces that ax2 has a same viewlim as the original
axes. You cannot manually change it.

-JJ




On Sun, Feb 1, 2009 at 12:41 PM, Eli Bressert
bress...@head.cfa.harvard.edu wrote:
 Hi,

 I'm looking into customizing the the tick positions on an imshow plot. I
 found that you can do this by doing

 img = imshow(data)
 img.ax.xaxis.set_ticks([100.,200.])


 The problem with this method is that it moves the tick positions on the
 bottom and top x axis. What if I wanted to do have the top axes show
 ticks at slightly different positions than the bottom one? Any ideas or
 suggestions would be greatly appreciated

 -Eli

 --
 This SF.net email is sponsored by:
 SourcForge Community
 SourceForge wants to tell your story.
 http://p.sf.net/sfu/sf-spreadtheword
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users