On Tue, Feb 8, 2011 at 6:53 AM, Curiouslearn <curiousle...@gmail.com> wrote:
> Hello,
>
> Matplotlib is so cool. I wish I had spent time learning it earlier.
> Better late than never. Thanks so much to all who have worked on
> developing it.
>
> I had a question on histograms. Instead of the bars in case of
> histograms, is there a way to get circle markers, where each marker
> represents one observation in that bin. For example, if there are 5
> observations in a bin, then instead of a bar of height 5, I want 5
> circles stacked on top of each other. The same for other bins. Is
> there a built-in command or property to do this?
>
> Thanks for your help.
>
>
Not exactly, but you could use numpy's histogram() function to get the
appropriate data and then plot the circles yourself using scatter():
hist, bins = np.histogram(data, bins=20)
fig = plt.figure()
ax = fig.gca()
for left, right, cnt in zip(bins[:-1], bins[1:], hist) :
x = [(left + right) / 2.0] * cnt
y = np.arange(cnt) + 0.5
ax.scatter(x, y, s=np.pi)
plt.show()
You will have to adjust the value of s in the call to scatter to get the
desired result. The units of s is points^2. Note that this wouldn't
necessarially "stack" the circles, and zooming in/out of the figure will not
change the size of the scatter points. To get more precise control of the
circles, you could look into creating the circle patches yourself:
http://matplotlib.sourceforge.net/api/artist_api.html?highlight=circle#matplotlib.patches.Circle
I hope this gets you started!
Ben Root
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users