ploting matrix data

Hi Bala,

you may want to have a look at the gallery including many example pictures on
http://matplotlib.sourceforge.net/gallery.html
especially the follwing two examples might be of interest for you
http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html
http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

I used these two to set up the attached example, which is very close to what
you want.

Question for developers: Could it be useful to add two kwargs 'over_color'
and 'under_color' to contourf in order to allow specification of a
ListedColormap by kwarg 'colors' and these two colors?

best regards
Matthias

contourf_with_extended_colorbar.py (1.61 KB)

···

On Thursday 09 April 2009 10:34:27 Bala subramanian wrote:

Dear Matthias,

Thanks a ton. This is a great help for me. Is there any way to specify a
color range. By default it has produced different colors at the interval of
0.3, i need bit higher range like < 1 , 1 to 1.5, 1.5-2.0, 2-2.5, > 2.5.
Also i need to set this range dynamically. Kindly write me how i can do
this.

Thanks in advance,
Bala

On Thu, Apr 9, 2009 at 9:08 AM, Matthias Michler <MatthiasMichler@...361...>wrote:
> Hi Bala,
>
> I added a small example showing up your matrix in order to have a running
> example, where you can specify your needs.
>
> In the program contourf could be replaced by contour or imshow - see
> help /
> docu / examples on the web
> The colormap can be specified with the kwarg "cmap" : e.g.
> pyplot.cm.gray.
>
> regards Matthias
>
> On Wednesday 08 April 2009 14:08:13 Bala subramanian wrote:
> > Friends,
> >
> > I have a pairwise comparison of 50 data points. The comparison is based
>
> on
>
> > the mean square deviation between the points. I want to plot this data
> > by specifying different colors for diffrent ranges of mean square
> > deviation. Any suggestion would be of much help to me. I have attached
> > the data file with the mail.
> >
> > Thanks,
> > Bala
>
> -------------------------------------------------------------------------
>----- This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hello list,

playing with the example program (contourf_with_extended_colorbar.py) I also
send in the last email and using random numbers I get the attached picture
(contourf_vs_contour_different_behavior.png), which shows up that contour and
contourf lines don't coinside. I thought that contour and contourf generate
the same lines and differ only in plotting. Is this just due to the random
numbers as an exceptional case or is this a bug?

Second question: Could it be useful to add two kwargs 'over_color'
and 'under_color' to contourf in order to allow specification of a extended
ListedColormap by kwarg 'colors' and these two colors?
I tried to include this in the attached patch
(added_under_and_over_color_to_ContourSet.patch) and use it in the example
contourf_with_extended_colorbar_new.py. But it dosn't work completely
correct. Although the over color is correctly set to cyan in the cmap
In [14]: my_contourf.cmap._rgba_over
Out[14]: (0.0, 1.0, 1.0, 1.0)
red is used for values above the colormap-bounds.

Thanks in advance for any comments and hints.

best regards Matthias

contourf_with_extended_colorbar.py (1.45 KB)

contourf_vs_contour_different_behavior.png

contourf_with_extended_colorbar_new.py (1.02 KB)

added_under_and_over_color_to_ContourSet.patch (2.58 KB)

···

On Thursday 09 April 2009 13:16:55 Matthias Michler wrote:

Hi Bala,

you may want to have a look at the gallery including many example pictures
on http://matplotlib.sourceforge.net/gallery.html
especially the follwing two examples might be of interest for you
http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.htm
l http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

I used these two to set up the attached example, which is very close to
what you want.

Question for developers: Could it be useful to add two kwargs 'over_color'
and 'under_color' to contourf in order to allow specification of a
ListedColormap by kwarg 'colors' and these two colors?

best regards
Matthias

On Thursday 09 April 2009 10:34:27 Bala subramanian wrote:
> Dear Matthias,
>
> Thanks a ton. This is a great help for me. Is there any way to specify a
> color range. By default it has produced different colors at the interval
> of 0.3, i need bit higher range like < 1 , 1 to 1.5, 1.5-2.0, 2-2.5, >
> 2.5. Also i need to set this range dynamically. Kindly write me how i can
> do this.
>
> Thanks in advance,
> Bala
>
> On Thu, Apr 9, 2009 at 9:08 AM, Matthias Michler > > <MatthiasMichler@...361...>wrote:
> > Hi Bala,
> >
> > I added a small example showing up your matrix in order to have a
> > running example, where you can specify your needs.
> >
> > In the program contourf could be replaced by contour or imshow - see
> > help /
> > docu / examples on the web
> > The colormap can be specified with the kwarg "cmap" : e.g.
> > pyplot.cm.gray.
> >
> > regards Matthias
> >
> > On Wednesday 08 April 2009 14:08:13 Bala subramanian wrote:
> > > Friends,
> > >
> > > I have a pairwise comparison of 50 data points. The comparison is
> > > based
> >
> > on
> >
> > > the mean square deviation between the points. I want to plot this
> > > data by specifying different colors for diffrent ranges of mean
> > > square deviation. Any suggestion would be of much help to me. I have
> > > attached the data file with the mail.
> > >
> > > Thanks,
> > > Bala

Matthias Michler wrote:

Hello list,

playing with the example program (contourf_with_extended_colorbar.py) I also send in the last email and using random numbers I get the attached picture (contourf_vs_contour_different_behavior.png), which shows up that contour and contourf lines don't coinside. I thought that contour and contourf generate the same lines and differ only in plotting. Is this just due to the random numbers as an exceptional case or is this a bug?

It is a bug that is inherent in the underlying contouring code. The code for filled contours is quite different, and more complicated, than for unfilled contours. I have been thinking about ways of solving this problem, unifying the line-finding methods for filled and unfilled contours, but it is not at all trivial.

Second question: Could it be useful to add two kwargs 'over_color' and 'under_color' to contourf in order to allow specification of a extended ListedColormap by kwarg 'colors' and these two colors?
I tried to include this in the attached patch (added_under_and_over_color_to_ContourSet.patch) and use it in the example contourf_with_extended_colorbar_new.py. But it dosn't work completely correct. Although the over color is correctly set to cyan in the cmap In [14]: my_contourf.cmap._rgba_over
Out[14]: (0.0, 1.0, 1.0, 1.0)
red is used for values above the colormap-bounds.

Thanks in advance for any comments and hints.

I need to look at your patch--but a priori, I am a bit worried about the tendency of APIs to get more and more complicated, with more and more kwargs, as time goes on.

Eric

···

best regards Matthias

On Thursday 09 April 2009 13:16:55 Matthias Michler wrote:

Hi Bala,

you may want to have a look at the gallery including many example pictures
on http://matplotlib.sourceforge.net/gallery.html
especially the follwing two examples might be of interest for you
http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.htm
l http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

I used these two to set up the attached example, which is very close to
what you want.

Question for developers: Could it be useful to add two kwargs 'over_color'
and 'under_color' to contourf in order to allow specification of a
ListedColormap by kwarg 'colors' and these two colors?

best regards
Matthias

On Thursday 09 April 2009 10:34:27 Bala subramanian wrote:

Dear Matthias,

Thanks a ton. This is a great help for me. Is there any way to specify a
color range. By default it has produced different colors at the interval
of 0.3, i need bit higher range like < 1 , 1 to 1.5, 1.5-2.0, 2-2.5, >
2.5. Also i need to set this range dynamically. Kindly write me how i can
do this.

Thanks in advance,
Bala

On Thu, Apr 9, 2009 at 9:08 AM, Matthias Michler >> <MatthiasMichler@...361...>wrote:

Hi Bala,

I added a small example showing up your matrix in order to have a
running example, where you can specify your needs.

In the program contourf could be replaced by contour or imshow - see
help /
docu / examples on the web
The colormap can be specified with the kwarg "cmap" : e.g.
pyplot.cm.gray.

regards Matthias

On Wednesday 08 April 2009 14:08:13 Bala subramanian wrote:

Friends,

I have a pairwise comparison of 50 data points. The comparison is
based

on

the mean square deviation between the points. I want to plot this
data by specifying different colors for diffrent ranges of mean
square deviation. Any suggestion would be of much help to me. I have
attached the data file with the mail.

Thanks,
Bala

------------------------------------------------------------------------

------------------------------------------------------------------------

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com

------------------------------------------------------------------------

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

Eric Firing wrote:

Matthias Michler wrote:

Hello list,

playing with the example program (contourf_with_extended_colorbar.py) I also send in the last email and using random numbers I get the attached picture (contourf_vs_contour_different_behavior.png), which shows up that contour and contourf lines don't coinside. I thought that contour and contourf generate the same lines and differ only in plotting. Is this just due to the random numbers as an exceptional case or is this a bug?

It is a bug that is inherent in the underlying contouring code. The code for filled contours is quite different, and more complicated, than for unfilled contours. I have been thinking about ways of solving this problem, unifying the line-finding methods for filled and unfilled contours, but it is not at all trivial.

And I need to add: it may be that the difference between filled and unfilled contours that you showed in your plot is not actually a consequence of the difference between the filled and unfilled code paths, but of the sequence of calls to the underlying code. So it is possible that when one wants both filled and unfilled contours, they could be made consistent via a refactoring of the internals of the ContourSet class, with corresponding changes in the Axes and pyplot APIs. Again, this is not trivial, but there is some refactoring I would like to do anyway to make it easier for people to access the results of the basic contour-finding, and this would go along with it.

I don't know when I will get around to actually working on this; probably not before this summer. If someone else wants to plunge in, that's fine. I can provide a few thoughts on what might be done.

Eric

Hello Eric,
Hello list,

Matthias Michler wrote:

[...]

> Second question: Could it be useful to add two kwargs 'over_color'
> and 'under_color' to contourf in order to allow specification of a
> extended ListedColormap by kwarg 'colors' and these two colors?
> I tried to include this in the attached patch
> (added_under_and_over_color_to_ContourSet.patch) and use it in the
> example contourf_with_extended_colorbar_new.py. But it dosn't work
> completely correct. Although the over color is correctly set to cyan in
> the cmap In [14]: my_contourf.cmap._rgba_over
> Out[14]: (0.0, 1.0, 1.0, 1.0)
> red is used for values above the colormap-bounds.
>
> Thanks in advance for any comments and hints.

I need to look at your patch--but a priori, I am a bit worried about the
tendency of APIs to get more and more complicated, with more and more
kwargs, as time goes on.

You are right too many kwargs can be a problem and I don't claim that this is
the right solution at this point, but I was somehow unhappy with my first
solution, where one needs to generate ones own ListedColormap. And this is
only due to the fact that one needs a colour for upper and lower values
otherwise everthing is handled by passing 'colors' to contourf.

best regards
Matthias

···

On Tuesday 14 April 2009 20:39:06 Eric Firing wrote: