コード例 #1
0
ファイル: test_root2matplotlib.py プロジェクト: ndawe/rootpy
def test_contour():
    from rootpy.plotting import root2matplotlib as rplt
    import numpy as np
    a = Hist2D(100, -3, 3, 100, 0, 6)
    a.fill_array(np.random.multivariate_normal(
        mean=(0, 3),
        cov=[[1, .5], [.5, 1]],
        size=(1000,)))
    rplt.contour(a)
コード例 #2
0
ファイル: test_root2matplotlib.py プロジェクト: suvayu/rootpy
def test_contour():
    from rootpy.plotting import root2matplotlib as rplt
    import numpy as np
    a = Hist2D(100, -3, 3, 100, 0, 6)
    a.fill_array(np.random.multivariate_normal(
        mean=(0, 3),
        cov=np.arange(4).reshape(2, 2),
        size=(1000,)))
    rplt.contour(a)
コード例 #3
0
def test_contour():
    from rootpy.plotting import root2matplotlib as rplt
    import numpy as np
    a = Hist2D(100, -3, 3, 100, 0, 6)
    a.fill_array(
        np.random.multivariate_normal(mean=(0, 3),
                                      cov=[[1, .5], [.5, 1]],
                                      size=(1000, )))
    rplt.contour(a)
コード例 #4
0
def test_contour():
    from rootpy.plotting import root2matplotlib as rplt
    import numpy as np
    a = Hist2D(100, -3, 3, 100, 0, 6)
    a.fill_array(
        np.random.multivariate_normal(mean=(0, 3),
                                      cov=np.arange(4).reshape(2, 2),
                                      size=(1000, )))
    rplt.contour(a)
コード例 #5
0
from rootpy.plotting import root2matplotlib
import rootpy.plotting
import numpy as np

a = rootpy.plotting.Hist2D(100, -3, 3, 100, 0, 6)
a.fill_array(np.random.multivariate_normal(
    mean=(0, 3),
    cov=np.arange(4).reshape(2, 2),
    size=(1E6,)))

fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(15, 5))

ax1.set_title('hist2d')
root2matplotlib.hist2d(a, axes=ax1)

ax2.set_title('imshow')
im = root2matplotlib.imshow(a, axes=ax2)

ax3.set_title('contour')
root2matplotlib.contour(a, axes=ax3)

fig.subplots_adjust(right=0.8)
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im, cax=cbar_ax)

fig.savefig(
    'hist2d.pdf',    # Name of the file
    bbox_inches='tight') 

#if not ROOT.gROOT.IsBatch():
#    plt.show()
コード例 #6
0
print(__doc__)
import ROOT
from matplotlib import pyplot as plt
from rootpy.plotting import root2matplotlib as rplt
from rootpy.plotting import Hist2D
import numpy as np

a = Hist2D(100, -3, 3, 100, 0, 6)
a.fill_array(np.random.multivariate_normal(
    mean=(0, 3),
    cov=[[1, .5], [.5, 1]],
    size=(1E6,)))

fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(15, 5))

ax1.set_title('hist2d')
rplt.hist2d(a, axes=ax1)

ax2.set_title('imshow')
im = rplt.imshow(a, axes=ax2)

ax3.set_title('contour')
rplt.contour(a, axes=ax3)

fig.subplots_adjust(right=0.8)
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im, cax=cbar_ax)

if not ROOT.gROOT.IsBatch():
    plt.show()
コード例 #7
0
print __doc__
import ROOT
from matplotlib import pyplot as plt
from rootpy.plotting import root2matplotlib as rplt
from rootpy.plotting import Hist2D
import numpy as np

a = Hist2D(100, -3, 3, 100, 0, 6)
a.fill_array(
    np.random.multivariate_normal(mean=(0, 3),
                                  cov=np.arange(4).reshape(2, 2),
                                  size=(1E6, )))

fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(15, 5))

ax1.set_title('hist2d')
rplt.hist2d(a, axes=ax1)

ax2.set_title('imshow')
im = rplt.imshow(a, axes=ax2)

ax3.set_title('contour')
rplt.contour(a, axes=ax3)

fig.subplots_adjust(right=0.8)
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im, cax=cbar_ax)

if not ROOT.gROOT.IsBatch():
    plt.show()
コード例 #8
0
		plt.close('all')

		if (MCSample,norm, label, firstInCombinedSample) in samplestooverlay:

			alpha = 0.7
			linestyle = 'solid'

			levels = [ round_to_1( MCScales[MCSample]*NEvent[MCSample]* tmpfactor )  for tmpfactor in [ 0.0001,0.001,0.01,0.1]   ]
			
			if colornorm==0:
				colornorm = matplotlib.colors.Normalize(vmin = 0 , vmax = 100, clip = False)

			# plt.grid()
			# # ims[MCSample] = rplt.imshow(a,axes=OverlayAxes, norm = colornorm, cmap = sns.blend_palette(["ghostwhite", colorpal[iSample]], as_cmap=True) , alpha=0.25 )
			ims[MCSample] = rplt.imshow (corrhist,axes=OverlayAxes, norm = colornorm, cmap = sns.blend_palette(["ghostwhite", colorpal[iSample]], as_cmap=True) , alpha=0.25 )
			ctr[MCSample] = rplt.contour(corrhist,axes=OverlayAxes,  linewidth=10, alpha=alpha, linestyles=linestyle , colors = matplotlib.colors.rgb2hex(colorpal[iSample]) ) #, locator=ticker.FixedLocator(levels) )
			plt.clabel(ctr[MCSample], inline=0, inline_spacing=-1, fontsize=10,fmt='%1.0f')
			OverlayAxes.annotate(r"\textbf{\textit{ATLAS}} Internal", xy=(0.65, 0.05), xycoords='axes fraction', fontweight='bold', fontsize=10)

			pass

	OverlayAxes.set_xlim(var1limits[:2])
	OverlayAxes.set_ylim(var2limits[:2])


	tmpRectangle = {}
	for iSample, (MCSample,norm, label, tmp) in enumerate(samplestodraw) :
		tmpRectangle[MCSample] = Rectangle((0, 0), 1, 1, fc=matplotlib.colors.rgb2hex(colorpal[iSample]) )
	OverlayAxes.legend([tmpRectangle[x] for  (x,y,z,x1) in samplestooverlay ], [z for (x,y,z,x1) in samplestooverlay],  loc="best" , borderaxespad=3)
	OverlayAxes.set_xlabel(var1label)
	OverlayAxes.set_ylabel(var2label)