SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S




1
(17)
2
(3)
3
(2)
4
(11)
5
(8)
6
(22)
7
(16)
8
(9)
9
(14)
10
(1)
11
(8)
12
(5)
13
(7)
14
(10)
15
(28)
16
(8)
17
(20)
18
(6)
19
(5)
20
(15)
21
(8)
22
(7)
23
(14)
24
(10)
25
(6)
26
(8)
27
(9)
28
(11)
29
(13)
30
(20)

Showing 8 results of 8

From: Isidora <is...@ju...> - 2011年09月26日 19:58:23
Hi,
I am trying to plot filled paths over a U.S. map. I plot the given paths, but since these are not closed paths, the filling is truncated at a line drawn between last and first point in the path. I want to extend the path to the United States border instead. 
I am no expert in matplotlib or GIS. Could anyone help me find documentation or blogs discussing this type of issue? I am convinced somebody else has already faced this problem although I have not been able to find any paper, documentation, blog on it. 
Thank you
From: John H. <jd...@gm...> - 2011年09月26日 17:27:18
On Mon, Sep 26, 2011 at 12:24 PM, John Hunter <jd...@gm...> wrote:
> On Mon, Sep 26, 2011 at 12:05 PM, Katie Boyle <kat...@gm...> wrote:
>> Hi All,
>>
>> I was wondering how I take a list of 250 discrete values and match up each
>> value in the list to a color in the gist_rainbow colormap. I want the
>> highest value to be red, and the lowest value to be blue. I then want to
>> plot a point for each value in the list, and the point's color should
>> represent its value. I cannot use contourf or any other function that does
>> this automatically on a continuous grid--I need to plot individual points.
>
> I think you are looking for "scatter", with the "c" argument being
> your intensity value. You can pass the gist_rainbow colormap to the
> scatter function via the cmap argument. See these examples
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo.html
> http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo2.html
Eg,
In [43]: x, y, c = np.random.randn(3, 100)
In [44]: plt.scatter(x, y, c=c, cmap='gist_rainbow')
Out[44]: <matplotlib.collections.PathCollection object at 0x981b22c>
From: John H. <jd...@gm...> - 2011年09月26日 17:25:10
On Mon, Sep 26, 2011 at 12:05 PM, Katie Boyle <kat...@gm...> wrote:
> Hi All,
>
> I was wondering how I take a list of 250 discrete values and match up each
> value in the list to a color in the gist_rainbow colormap. I want the
> highest value to be red, and the lowest value to be blue. I then want to
> plot a point for each value in the list, and the point's color should
> represent its value. I cannot use contourf or any other function that does
> this automatically on a continuous grid--I need to plot individual points.
I think you are looking for "scatter", with the "c" argument being
your intensity value. You can pass the gist_rainbow colormap to the
scatter function via the cmap argument. See these examples
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo.html
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo2.html
From: Katie B. <kat...@gm...> - 2011年09月26日 17:05:39
Hi All,
I was wondering how I take a list of 250 discrete values and match up each
value in the list to a color in the gist_rainbow colormap. I want the
highest value to be red, and the lowest value to be blue. I then want to
plot a point for each value in the list, and the point's color should
represent its value. I cannot use contourf or any other function that does
this automatically on a continuous grid--I need to plot individual points.
I have tried creating my own colormap with:
my_colors = matplotlib.colors.Colormap(my_list)
but when I issue a pyplot.plot() command with the argument cmap=my_colors, I
get "TypeError: There is no patch property "cmap"
How do I do this correctly?
Cheers,
Katie
From: Bala s. <bal...@gm...> - 2011年09月26日 09:05:08
Friends,
I have solved the problem by myself. I gave
if w < 2.0: color = 'red'
if 2.1 < w > 4.0: color='blue' So wherever the value there is a value like
2.03 or 2.05, the color was shown as black instead of red/blue.
Thanks,
Bala
On Mon, Sep 26, 2011 at 9:25 AM, Bala subramanian <bal...@gm...
> wrote:
> Friends,
> In the mpl site, i found the an example code called hinton_demo to plot
> weighted matrix in the following link.
>
>
> http://matplotlib.sourceforge.net/examples/api/hinton_demo.html?highlight=hinton
>
> I used the same script (attached test.py) making a slight modification in
> the following section of the code pasted below. I just included more color
> range and modified the size as np.sqrt(np.abs(w))/5.
>
> However when i run the script with test data (attached test.dat), i found
> that the size of the square and color are not matching. For instance the
> size of the squares at position 4,3 and 7,6 are small but the color (black)
> is not relevant to the size. I am not getting what is going wrong. Kindly
> help to resolve the problem.
>
> The script and test data are attached.
>
> *Section of the code modified*
>
> for (x,y),w in np.ndenumerate(W):
> if w > 0: color = 'white'
> else: color = 'black'
> size = np.sqrt(np.abs(w))
> rect = Rectangle([x - size / 2, y - size / 2], size, size,
> facecolor=color, edgecolor=color)
> ax.add_patch(rect)
>
>
From: getnut <ale...@ho...> - 2011年09月26日 09:01:51
Hi,
 I try to apply contrast to an image with set_cmap() like it's explained
in this page http://matplotlib.sourceforge.net/users/image_tutorial.html
http://matplotlib.sourceforge.net/users/image_tutorial.html but when I
apply a new pseudocolor nothing appends. Please help me! This is my code.
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.cm as cm
import numpy as np
import sys
turno=0
pixel=0
img16=open(sys.argv[1],'r')
r=img16.read(2)
val=[]
i=0
riga=[]
while r !="":
	if (pixel>=0) & (pixel<510):
		r1=ord(r[0])
		r2=(ord(r[1])&15)<<8
		ris=(float(r1|r2))/4095
		riga.append([ris,ris,ris])
	else:
		if pixel==511:
			val.append(riga)
			riga=[]
	pixel=(pixel+1)%512
	r=img16.read(2)
#for i in range(512):
#	print len(val[i])
#	print val[i]
val=np.array(val,dtype=np.float32)
imgplot = plt.imshow(val)
imgplot.set_cmap(cm.binary)
plt.show()
-- 
View this message in context: http://old.nabble.com/contrast-image-tp32503930p32503930.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Angus M. <am...@gm...> - 2011年09月26日 08:09:51
On 25 September 2011 06:59, fdu...@gm... <fdu...@gm...> wrote:
> Dear all,
>
> Heatmap (like those on the page
> http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/)
> is a frequently used type of image in microarray data analysis. However,
> it seems there are no convenient functions in matplotlib to plot heatmap
> (please correct me if I was wrong), so I'm planning to write my own.
>
> Let me take the heatmap by the link
> http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/r/heatmap/scaled_color_key.png
> as an example, which is produced by R.
>
> With my limited knowledge and expertise of matplotlib, I have the
> following questions and I hope you guys could help me.
>
> 1) I tend to use pcolor to draw the colormap in the central area.
> However, I've seen a lot of examples draw colormap with imshow.
>
>   What's the difference between pcolor and imshow?
>   Shall I use pcolor or imshow to produce the heatmap in the link above?
One difference between pcolor and imshow is that pcolor lines up the
bottom-left corner of each square with the co-ordinates given, whereas
imshow puts the grid center at those co-ordinates. My guess would be
(not having implemented a heatmap) that pcolor would be the more
useful to you to try first for this reason.
> 2) How to draw the dendrograms on the top and left of the colormap?
>
>   I got hints from
> http://matplotlib.sourceforge.net/examples/axes_grid/scatter_hist.html
> on how to append axes to current plot, but I still have now idea how to
> draw the dengrograms.
A quick google search suggests that scipy-cluster might help you out
with the dendrogram drawing. I think I would try using separate axes
objects for the heatmap and the dendrograms, and switch off the frames
of the dendrogram axes.
> 3) How to draw the column side colormap (the smaller one) between the
> top dendrogram and the big colormap?
This could another axes object too. You can use the sharex keyword to
add_axes to get it to have the same x scale as the big axes.
> 4) I can use colorbar to draw a colorbar, but how to place the colorbar
> on the topleft of the image just as the R heatmap does?
Again, the answer is to manually create the axes for your colorbar,
and then specify those axes in the call to colorbar using the `cax`
keyword.
> 5) Any other suggestions on how to draw the heatmap?
I suggest that you give it a try and post your efforts here if there
are any problems. We'll also be keen to see the final result, if you'd
like to share it.
I hope that helps at least a little. Happy coding,
Angus
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
From: Bala s. <bal...@gm...> - 2011年09月26日 07:25:23
Attachments: test.py test.dat
Friends,
In the mpl site, i found the an example code called hinton_demo to plot
weighted matrix in the following link.
http://matplotlib.sourceforge.net/examples/api/hinton_demo.html?highlight=hinton
I used the same script (attached test.py) making a slight modification in
the following section of the code pasted below. I just included more color
range and modified the size as np.sqrt(np.abs(w))/5.
However when i run the script with test data (attached test.dat), i found
that the size of the square and color are not matching. For instance the
size of the squares at position 4,3 and 7,6 are small but the color (black)
is not relevant to the size. I am not getting what is going wrong. Kindly
help to resolve the problem.
The script and test data are attached.
*Section of the code modified*
for (x,y),w in np.ndenumerate(W):
 if w > 0: color = 'white'
 else: color = 'black'
 size = np.sqrt(np.abs(w))
 rect = Rectangle([x - size / 2, y - size / 2], size, size,
 facecolor=color, edgecolor=color)
 ax.add_patch(rect)

Showing 8 results of 8

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /