[Matplotlib-users] question about stacked histograms

2009-06-02 Thread Amit
Hi all,

Has any of you had any luck with creating stacked histograms using 
matplotlib? It seems to work but I have no idea how to label (or add the 
legend) or choose the colors of the stacks. Below is a sample code for 
creating a stacked histogram. Can anyone help please? Unlike the "bar()" 
function, hist() doesn't seem to have the color/colors parameter.

#!/usr/bin/python

import sys
import matplotlib.pyplot as pyplot
import numpy as numpy

page_numbers_one = (100,100,500,600,800)
page_numbers_two = (100,100,500,600,800,100,100,100,100,100)
page_numbers_three = (900,100,500,600,800,500)

pyplot.hist((page_numbers_one,page_numbers_two,page_numbers_three),histtype='barstacked',bins=5)

pyplot.show()

best,
amit shrestha

--
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] question about stacked histograms

2009-06-03 Thread Amit
Thanks John. The bar_stacked example does not seem to work for histograms, but I'm glad to know that we could manually make the legends. 


I still do not know how to specify the colors of the "stacks" in my histogram, 
so adding the manual legends for them is still a pain -- but at least doable since I can 
figure it out from the actual data.

best,
amit shrestha

John Hunter wrote:

On Tue, Jun 2, 2009 at 3:15 PM, Amit  wrote:
  

Hi all,

Has any of you had any luck with creating stacked histograms using
matplotlib? It seems to work but I have no idea how to label (or add the
legend) or choose the colors of the stacks. Below is a sample code for
creating a stacked histogram. Can anyone help please? Unlike the "bar()"
function, hist() doesn't seem to have the color/colors parameter.

#!/usr/bin/python

import sys
import matplotlib.pyplot as pyplot
import numpy as numpy

page_numbers_one = (100,100,500,600,800)
page_numbers_two = (100,100,500,600,800,100,100,100,100,100)
page_numbers_three = (900,100,500,600,800,500)

pyplot.hist((page_numbers_one,page_numbers_two,page_numbers_three),histtype='barstacked',bins=5)

pyplot.show()




Have you seen this example:

  http://matplotlib.sourceforge.net/examples/pylab_examples/bar_stacked.html

To create the legend, it is best to create proxy objects, eg
Rectangles, with the right colors and manually add them to the legend.
See

  
http://matplotlib.sourceforge.net/users/plotting/legend.html#using-proxy-artist

JDH
  


--
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Axis default limits with a Circle patch

2014-11-11 Thread Amit Saha
Hi all,

Consider the following code:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca()
circle = plt.Circle((0, 0), radius = 0.5)
ax.add_patch(circle)
print(plt.axis())
plt.show()

The default axis limits are printed as:

(0.0, 1.0, 0.0, 1.0)

I am not sure why this is the case. So, I would like to learn why?

PS: I know I can just do plt.axis('scaled') so that I can see the entire circle.

I also asked this on SO, so feel free to answer there as well:
http://stackoverflow.com/questions/26824696/matplotlib-axis-default-limits-with-a-circle-patch

Thanks,
-Amit.

-- 
http://echorand.me

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Histogram appearance

2014-12-03 Thread Amit Saha
Hi,

Please find attached a simple histogram created using the hist()
function. Any idea why the last two bars are squeezed into each other?
Is there a simple way to fix this while plotting?

Thanks,
Amit.
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Histogram appearance

2014-12-03 Thread Amit Saha
On Thu, Dec 4, 2014 at 6:45 AM, Brendan Barnwell  wrote:
> On 2014-12-03 12:39, Amit Saha wrote:
>>
>> Hi,
>>
>> Please find attached a simple histogram created using the hist()
>> function. Any idea why the last two bars are squeezed into each other?
>> Is there a simple way to fix this while plotting?
>
>
> It looks like the bins are set up so that there are empty bins
> between each of the other bars.  How are you setting the bins?  You could
> try adjusting the bin boundaries.

Thanks for the reply. This is my program:

import matplotlib.pyplot as plt
import random

def roll():
return random.randint(1, 6)

if __name__ == '__main__':
rolls = []
for i in range(1000):
rolls.append(roll())
# create a histogram plot
plt.hist(rolls)
plt.show()


So, just using the hist() function for now.

Thanks, Amit.

>
> --
> Brendan Barnwell
> "Do not follow where the path may lead.  Go, instead, where there is no
> path, and leave a trail."
>--author unknown



-- 
http://echorand.me

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Histogram appearance

2014-12-15 Thread Amit Saha
Hi,

On Thu, Dec 4, 2014 at 7:01 AM, Dino Bektešević  wrote:
> Hello,
>
> try doing:
>
> import matplotlib.pyplot as plt
> import random
>
> rolls = list()
> for i in range(1000):
> rolls.append(random.randint(1,6))
>
>
> plt.hist(rolls, bins=6)
> plt.show()
>
> Reason why your histogram is weird is because you only can have 6 bins
> in your example. But the default bin number for hist function is 10.
> The borders of bins are therefore set at half intervals. When you roll
> 1, bin 0 to 0.6 gets incremented, when you roll 2.2 bin 2-2.6 gets
> incremented, but the bin 0.6-2.2 never does.

Thanks. That helps me in my understanding. Choosing bins = 6 fixes the
problem I reported.

Best,
Amit.

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Newbie Q re: Lorenz attractor

2015-03-08 Thread Amit Saha
On Mon, Mar 9, 2015 at 7:31 AM, Prahas David Nafissian
 wrote:
> Hi,
>
> I want to create an animation of the Lorenz attractor,
> plotting each new point as it is generated by the
> equations.  So we see the graph "being drawn"
> over time.

You will very likely need to use the animation API for this. I
recently tried to demonstrate the Henon function in a fashion that it
appears I am drawing it over time:
https://www.youtube.com/watch?v=76ll818RlpQ

You can see the code linked from there:
https://github.com/amitsaha/playground/blob/master/recipes/henon_animation.py

That might give you a starting point of what you are trying to do.

>
> Also, as it is being drawn, I want to be able to
> rotate the screen in 3 dimensions.

Sorry, nothing much I can add here.

Best,
Amit.

-- 
http://echorand.me

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] imshow() and pixel intensity

2015-05-17 Thread Amit Saha
Hi all,

Just trying to understand how the value of the matrix fed to imshow()
function determines the intensity of the pixel in grey scale mode.
Consider the example code:

import random
import matplotlib.pyplot as plt
import matplotlib.cm as cm

def pixels(n=3):
pixel_data = []
for _ in range(n):
row = []
for _ in range(n):
row.append(random.randint(1, 10))
pixel_data.append(row)
return pixel_data

if __name__ == '__main__':
pixel_data = pixels()
print(pixel_data)
plt.imshow(pixel_data, origin='lower', cmap=cm.Greys_r)
plt.show()


The pixel_data here is the 3*3 "matrix":
[[7, 4, 6], [7, 7, 6], [4, 7, 9]]

How does the values here determine what shade of grey I see in the image?

Thank you in advance.

Best,
Amit.


-- 
http://echorand.me

--
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] imshow() and pixel intensity

2015-05-18 Thread Amit Saha
Got my answer here:
http://stackoverflow.com/questions/30301986/matplotlib-imshow-and-pixel-intensity



On Sun, May 17, 2015 at 10:02 PM, Amit Saha  wrote:
> Hi all,
>
> Just trying to understand how the value of the matrix fed to imshow()
> function determines the intensity of the pixel in grey scale mode.
> Consider the example code:
>
> import random
> import matplotlib.pyplot as plt
> import matplotlib.cm as cm
>
> def pixels(n=3):
> pixel_data = []
> for _ in range(n):
> row = []
> for _ in range(n):
> row.append(random.randint(1, 10))
> pixel_data.append(row)
> return pixel_data
>
> if __name__ == '__main__':
> pixel_data = pixels()
> print(pixel_data)
> plt.imshow(pixel_data, origin='lower', cmap=cm.Greys_r)
> plt.show()
>
>
> The pixel_data here is the 3*3 "matrix":
> [[7, 4, 6], [7, 7, 6], [4, 7, 9]]
>
> How does the values here determine what shade of grey I see in the image?
>
> Thank you in advance.
>
> Best,
> Amit.
>
>
> --
> http://echorand.me



-- 
http://echorand.me

--
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot() and imshow() relationship

2015-05-29 Thread Amit Saha
Hi all,

I  am trying to understand if there is a way to compare how plot() and
imshow() works for the case where I am not using imshow() to display
an image.

Via the plot() function, I am specifying the points that I want to
plot and also optionally the color that i want the points to be in.
For example, plot([1, 2, 3], [2, 3, 4], 'ro') will create a plot with
those points colored "red". Via the imshow() function, we specify the
color (or intensity) of each point and a figure is created with the
points colored accordingly. Sure, imshow() allows me to color each
point differently.

Is there a way to relate them?

Also asked on StackOverflow:
http://stackoverflow.com/questions/30527811/plot-and-imshow-relationship

Thanks,
Amit.


-- 
http://echorand.me

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


Re: [Matplotlib-users] plot() and imshow() relationship

2015-06-16 Thread Amit Saha
On Sat, May 30, 2015 at 1:50 AM, Paul Hobson  wrote:
> imshow is for displaying arrays as images/rasters.
>
> plot is for showing data/functions as points and lines.
>
> See the gallery for imshow:
> http://matplotlib.org/gallery.html#images_contours_and_fields

Thanks Paul. I have since then have been able to develop a better
understanding of imshow() and it doesn't seem very sensible to try and
compare/relate it to what plot() does.



-- 
http://echorand.me

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


[Matplotlib-users] colorbar() ticklabel color

2010-11-29 Thread Amit Finkler
Hi,


I am trying to produce a pcolor figure with a black background using

pylab.figure(facecolor = 'black')

Consequently, I need to change the tick colors and xlabel and ylabel
colors to white using

pylab.xlabel('whatever is on the xlabel', color = 'white', fontsize
= 14)
pylab.ylabel('whatever is on the ylabel', color = 'white', fontsize
= 14)

pylab.yticks(color = 'white')
pylab.xticks(color = 'white')


Up to this point, everything is OK. The next thing I need to do is
change the colors of the ticks and the ticklabels in the colorbar. I
understand that there are no simple pylab. commands which do so. I saw
in some matplotlib-users messages that one can write the following to
change the fontsize, for example:

for t in cb.ax.get_yticklabels():
 t.set_fontsize(14)


I tried adding another line to this loop:

 t.set_color('white')


On one hand, there is no error message during parsing or compilation. On
the other hand, nothing actually changes, i.e. the color of the
ticklabels and ticks stays black.


How does one change this property?


Amit


--
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Labels in a dynamic graph

2008-03-25 Thread Amit Finkler


John Hunter wrote:
> On Sun, Mar 23, 2008 at 3:54 AM, Amit Finkler <[EMAIL PROTECTED]> wrote:
>
>   
>> I am using matplotlib to dynamically plot a graph with both my x and y
>> points taken from a measurement device. That is to say, in each iteration of
>> my while loop I'm reading two variables which I then want to plot with
>> matplotlib.
>> 
>
> You will want to do something like (this is just a sketch)
>
> xdata = []
> ydata = []
>
> fig = figure()
> ax = fig.add_subplot(111)
> ax.set_xlabel('my xlabel')
> ax.set_ylabel('my ylabel')
> line, = ax.plot(xdata, ydata)
>
> def add_point(x, y):
> xdata.append(x)
> ydata.append(y)
> if len(xdata)>30:  # optional, prune the early points
> del xdata[0]
> del ydata[0]
> xmin = xdata[0]
> xmax = xdata[-1]
> line.set_data(xdata, ydata)
> ax.set_xlim(xmin, xmax)
> fig.canvas.draw()
>
> while 1:
> x,y = get_data_point()
> add_point(x, y)
>
> JDH
>   
John,

Thanks for getting back to me. Indeed this works, at least when I try it
line by line. When I inserted it into my module, it shot back some error
message which goes like this:

  File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 154, in draw
FigureCanvasAgg.draw(self)
  File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 392, in draw
self.figure.draw(renderer)
  File "/usr/lib/python2.4/site-packages/matplotlib/figure.py", line
544, in draw
for a in self.axes: a.draw(renderer)
  File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line
1004, in draw
try: self.transData.freeze()  # eval the lazy objects
ValueError: Domain error on eval_scalars in Transformation::freeze

Since it did work on the console, i.e., line by line, I think it's only
a matter of resolving my own source code, unless of course you think
otherwise. By the way, isn't there a way to do the set_xlim/ylim
automatically? When I use only figure(), hold(False) and plot(X, Y), it
updates it automatically, so why doesn't it do it with the subplot?

Thanks for your help.

Amit.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users