Histogram - dots/circle markers

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.

···

On Tue, Feb 8, 2011 at 5:25 AM, sanders <sanders@...3329...> wrote:

Hi,

I want to update the number of columns in my legend. How should I do that?

I'm looking for something like:

fig = plt.figure()
ax = fig.add_subplot(111)
my_own_plot_function(ax, data) # gives, for example, one column legend by
default
legend = ax.get_legend()
legend.set_ncol(2) # something like this

However, ncol is not in the legend.properties() list for properties to be
set through legend.set.

Thanks for any help,
Bram

------------------------------------------------------------------------------
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
matplotlib-users List Signup and Options

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

···

On Tue, Feb 8, 2011 at 6:53 AM, Curiouslearn <curiouslearn@…120…287…> 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.