thank you very much for this (i include your code below).
one question about this: how can i remove the top x-axis and the right yaxis from each of the marginal histograms? in other words, keep only the left y-axis and the bottom x-axis of each of the histograms.
thank you.
mport numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
x = np.random.randn(1000)
y = np.random.randn(1000)
nullfmt = NullFormatter() # no labels
left, width = 0.1, 0.65
bottom, height = 0.1, 0.65
bottom_h = left_h = left+width+0.02
rect1 = [left, bottom, width, height]
rect2 = [left, bottom_h, width, 0.2]
rect3 = [left_h, bottom, 0.2, height]
start with a rectangular figure
#fig = plt.Figure( (8,8) )
axScatter = plt.axes(rect1)
axHistx = plt.axes(rect2)#, sharex=axScatter)
axHisty = plt.axes(rect3)#, sharey=axScatter)
axHistx.xaxis.set_major_formatter(nullfmt)
axHisty.yaxis.set_major_formatter(nullfmt)
axScatter.scatter(x,y)
bins = np.linspace(-4,4,21)
axHistx.hist(x, bins=bins)
axHisty.hist(x, bins=bins, orientation=‘horizontal’)
axHistx.set_xlim( axScatter.get_xlim() )
axHisty.set_ylim( axScatter.get_ylim() )
plt.show()
···
On Mon, Feb 16, 2009 at 8:22 AM, Manuel Metz <mmetz@…1721…> wrote:
Attached is a very simple example that shows how to do something similar
to scatterhist in matplotlib
Manuel
per freem wrote:
hello,
is there a way to make a 2d scatter plot that includes (outside the axes)
histograms of the marginals of the two variables? like the matlab function
‘scatterhist’. see this for an example:
http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/scatterhist.html
ideally i’d like the histograms outside the scatter plot to also have axes
so that the height of each histogram bar will be interpretable.
i understand that there’s no command for this - but how can i construct it?
i would not mind writing code to do this… if it’s possible. right now
this is the only thing keeping me from switching from matlab to matplotlib
exclusively since i use these graphs a lot
thank you
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users