...
In examples below we assume
Code Block |
---|
fig = plt.figure(num=1, figsize=(10,10), dpi=100, facecolor='w',edgecolor='w',frameon=True)
axes = fig.add_subplot(111)
axim = axes.imshow(arrwin, interpolation='nearest', origin='bottom', aspect='auto')
|
How to
...
draw histogram
Code Block |
---|
fig = plt.figure(figsizeaxes.hist(arr, bins=100, range=(10,1050), log=False) # log for vertical scale only
|
How to draw graphic
Code Block |
---|
axes.plot(xarr1, yarr1, '-r', xarr2, yarr2, '-g')
|
How to define subplot with empty axes
Code Block |
---|
dpi=100, facecolor='w',edgecolor='w',frameon=True)
axes = fig.add_subplot(111)
axes.set_xlim((-50,1750))
axes.set_ylim((-50,1750))
|
How to make figure with non-equal subplots
Code Block |
---|
import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(20, 20)
# Naive direction [ Y , X ]
axsa = fig.add_subplot(gs[ 1:16, 0:14])
axsb = fig.add_subplot(gs[ 1:16, 14:19])
axsc = fig.add_subplot(gs[16: , 0:14])
|
or even simpler:
Code Block |
---|
axgr = fig.add_axes([0.1, 0.64, 0.80, 0.35])
axhi = fig.add_axes([0.1, 0.14, 0.35, 0.35])
axti = fig.add_axes([0.55, 0.14, 0.35, 0.35])
|
How to draw line
Code Block |
---|
import matplotlib.lines as lines
line = lines.Line2D(arrx, arry, linewidth=1, color='r')
axes.add_artist(line)
|
...
Code Block |
---|
axes.xaxis.set_ticks_position('top')
axes.yaxis.set_ticks_position('right')
|
How to make figure with non-equal subplots
Code Block |
---|
import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(20, 20)
# Naive direction [ Y , X ]
axsa = fig.add_subplot(gs[ 1:16, 0:14])
axsb = fig.add_subplot(gs[ 1:16, 14:19])
axsc = fig.add_subplot(gs[16: , 0:14])
|
or even simpler:
Code Block |
---|
axgr = fig.add_axes([0.1, 0.64, 0.80, 0.35])
axhi = fig.add_axes([0.1, 0.14, 0.35, 0.35])
axti = fig.add_axes([0.55, 0.14, 0.35, 0.35])
|
How to draw a color bar as a separate sub-plot
...