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 
Python :: True Positive, True Negative, False Positive, False Negative in scikit learn 
Python :: sns prevent legend 
Python :: how to get max value and min values in entire dataframe 
Python :: how to make bak files with python 
Python :: how to get the output in rupees in pandas 
Python :: split custom pytorch dataset 
Python :: python boucle for 
Python :: triplets in python 
Python :: add space before and after string python 
Python :: python elementTree tostring write() argument must be str, not bytes 
Python :: python function overloading 
Python :: python enable pyqt errors 
Python :: python typewriter effect 
Python :: how to install dependencies python 
Python :: ljust rjust center python 
Python :: how to stop python for certain time in python 
Python :: count number of subdirectories 
Python :: get diagonals of 2d array 
Python :: 151 - Power Crisis solution 
Python :: python system performance 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =