|
48 | 48 | # directory for storing temporary *.gp and *.gs files
|
49 | 49 | _user_path = os.path.join(os.environ['HOME'],'.gist')
|
50 | 50 |
|
51 |
| -def histogram(data,nbins=80,range=None,ntype=0,bar=1,bwidth=0.8,bcolor='fg'): |
| 51 | +def histogram(data,nbins=80,range=None,ntype=0,bar=1,bwidth=0.8,bcolor='fg',rval=False): |
52 | 52 | '''Plot a histogram.
|
53 | 53 |
|
54 | 54 | Returns an array (nbins,2) of bin values,count.
|
@@ -83,10 +83,16 @@ def histogram(data,nbins=80,range=None,ntype=0,bar=1,bwidth=0.8,bcolor='fg'):
|
83 | 83 | barplot(arr[:,0],arr[:,1],width=bwidth,color=bcolor)
|
84 | 84 | else:
|
85 | 85 | plot(arr[:,0],arr[:,1])
|
86 |
| - return arr |
| 86 | + if rval: return arr |
87 | 87 |
|
88 | 88 | def barplot(x,y,width=0.8,color='fg', horiz=False):
|
89 | 89 | '''Plot a barplot.
|
| 90 | + |
| 91 | + X X |
| 92 | + X X X |
| 93 | + X X X X X X X |
| 94 | +
|
| 95 | + SEE ALSO: stem, stairplot |
90 | 96 |
|
91 | 97 | x -- Centers of bars
|
92 | 98 | x -- Heights of bars
|
@@ -768,8 +774,10 @@ def stem(y, x=None, linetype='b-', mtype='mo', shift=0.013):
|
768 | 774 | y,x -- data points
|
769 | 775 | linetype -- type,color,marker,mark for lines
|
770 | 776 | mtype -- type,color,marker,mark for marker
|
| 777 | + |
| 778 | + EXAMPLE: stem(np.random.rand(10)) |
771 | 779 |
|
772 |
| - SEE ALSO: stairplot |
| 780 | + SEE ALSO: stairplot, barplot |
773 | 781 | '''
|
774 | 782 | y0 = numpy.zeros(len(y),y.dtype.char)
|
775 | 783 | y1 = y
|
@@ -894,7 +902,7 @@ def twoplane(DATA,slice1,slice2,dx=[1,1,1],cmin=None,cmax=None,xb=None,xe=None,
|
894 | 902 | xwidth = rescale * xwidth
|
895 | 903 | height1 = rescale * height1
|
896 | 904 | totalheight = totalheight * rescale
|
897 |
| - print((xwidth, height1)) |
| 905 | + print(xwidth, height1) |
898 | 906 | else:
|
899 | 907 | print(xwidth)
|
900 | 908 | ystart = 0.5 - totalheight / 2
|
@@ -1084,7 +1092,7 @@ def stairplot(a,*arg,**kwd):
|
1084 | 1092 | | |_| |_
|
1085 | 1093 | _| |_
|
1086 | 1094 |
|
1087 |
| - SEE ALSO: stem |
| 1095 | + SEE ALSO: stem, barplot |
1088 | 1096 | '''
|
1089 | 1097 | if type(a)==numpy.ndarray and len(a.shape)==2:
|
1090 | 1098 | xs=a[:,0]
|
@@ -1352,3 +1360,5 @@ def colorbar (minz, maxz, ncol = 255, ymax=0.85, ymin=0.44, xmin0=0.62, xmax0=0.
|
1352 | 1360 | if zlabel:
|
1353 | 1361 | ymidpt = (ymax+ymin)/2.0
|
1354 | 1362 | plt(zlabel, xmin0, ymidpt, color=color,font=font, justify='CB', height=fontsize, orient=1)
|
| 1363 | + |
| 1364 | + |
0 commit comments