Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add colorbar without changing subplot size

from mpl_toolkits.axes_grid1 import ImageGrid

x = np.random.random(size=(10,10))


fig = plt.figure()
grid = ImageGrid(fig, 111,
                nrows_ncols = (1,2),
                axes_pad = 0.05,
                cbar_location = "right",
                cbar_mode="single",
                cbar_size="5%",
                cbar_pad=0.05
                )

grid[0].imshow(x)
grid[0].axis('off')
grid[0].set_title('dog')

imc = grid[1].imshow(x, cmap='hot', interpolation='nearest')
grid[1].axis('off')
grid[1].set_title('dog')

plt.colorbar(imc, cax=grid.cbar_axes[0])
Comment

PREVIOUS NEXT
Code Example
Python :: python decomposition facteur premier 
Python :: python email subject decode 
Python :: python del var if exists 
Python :: creating a dictionary from lists 
Python :: python list comprehension nested loop 
Python :: how to print list without newline 
Python :: join function 
Python :: matplotlib ax.annotate color of the arrow 
Python :: python arabic web scraping 
Python :: symbolic variables python 
:: True Positive, True Negative, False Positive, False Negative in scikit learn 
Python :: how to find pdf file in link beautifulsoup 
Python :: python concatenate list of lists 
Python :: python get colorscale 
Python :: maya python override color rgb 
Python :: inicio programacao python 
Python :: reverse order of dataframe rows 
Python :: group a dataset 
Python :: spacy create tokenizer 
Python :: python all option 
Python :: empty array numpy python 
Python :: dataframe divided by rowsum 
Python :: fonts in python 
Python :: python avg 
Python :: choice without replacement python 
Python :: how to stop python for some time in python 
Python :: string remove ,replace, length in python 
Python :: python3 conditional with boolean 
Python :: 151 - Power Crisis 
Python :: how to add items to a set in python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =