Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

In matplotlib create subplot with different size

# importing required library
import matplotlib.pyplot as plt
import numpy as np
 
# creating grid for subplots
fig = plt.figure()
fig.set_figheight(6)
fig.set_figwidth(6)
 
ax1 = plt.subplot2grid(shape=(3, 3), loc=(0, 0), colspan=3)
ax2 = plt.subplot2grid(shape=(3, 3), loc=(1, 0), colspan=1)
ax3 = plt.subplot2grid(shape=(3, 3), loc=(1, 2), rowspan=2)
ax4 = plt.subplot2grid((3, 3), (2, 0))
ax5 = plt.subplot2grid((3, 3), (2, 1), colspan=1)
 
 
# initializing x,y axis value
x = np.arange(0, 10, 0.1)
y = np.cos(x)
 
# plotting subplots
ax1.plot(x, y)
ax1.set_title('ax1')
ax2.plot(x, y)
ax2.set_title('ax2')
ax3.plot(x, y)
ax3.set_title('ax3')
ax4.plot(x, y)
ax4.set_title('ax4')
ax5.plot(x, y)
ax5.set_title('ax5')
 
# automatically adjust padding horizontally
# as well as vertically.
plt.tight_layout()
 
# display plot
plt.show()
Comment

matplotlib insert small subplot into subplot

from mpl_toolkits.axes_grid.inset_locator import inset_axes
inset_axes = inset_axes(parent_axes,
                    width="30%", # width = 30% of parent_bbox
                    height=1., # height : 1 inch
                    loc=3)
Comment

matplotlib insert small subplot into subplot

from mpl_toolkits.axes_grid1.inset_locator import inset_axes
inset_axes = inset_axes(parent_axes,
                    width="30%", # width = 30% of parent_bbox
                    height=1., # height : 1 inch
                    loc=3)
Comment

In matplotlib create subplot with different size

# importing required library
import matplotlib.pyplot as plt
import numpy as np
 
# creating grid for subplots
fig = plt.figure()
fig.set_figheight(6)
fig.set_figwidth(6)
 
ax1 = plt.subplot2grid(shape=(3, 3), loc=(0, 0), colspan=3)
ax2 = plt.subplot2grid(shape=(3, 3), loc=(1, 0), colspan=1)
ax3 = plt.subplot2grid(shape=(3, 3), loc=(1, 2), rowspan=2)
ax4 = plt.subplot2grid((3, 3), (2, 0))
ax5 = plt.subplot2grid((3, 3), (2, 1), colspan=1)
 
 
# initializing x,y axis value
x = np.arange(0, 10, 0.1)
y = np.cos(x)
 
# plotting subplots
ax1.plot(x, y)
ax1.set_title('ax1')
ax2.plot(x, y)
ax2.set_title('ax2')
ax3.plot(x, y)
ax3.set_title('ax3')
ax4.plot(x, y)
ax4.set_title('ax4')
ax5.plot(x, y)
ax5.set_title('ax5')
 
# automatically adjust padding horizontally
# as well as vertically.
plt.tight_layout()
 
# display plot
plt.show()
Comment

matplotlib insert small subplot into subplot

from mpl_toolkits.axes_grid.inset_locator import inset_axes
inset_axes = inset_axes(parent_axes,
                    width="30%", # width = 30% of parent_bbox
                    height=1., # height : 1 inch
                    loc=3)
Comment

matplotlib insert small subplot into subplot

from mpl_toolkits.axes_grid1.inset_locator import inset_axes
inset_axes = inset_axes(parent_axes,
                    width="30%", # width = 30% of parent_bbox
                    height=1., # height : 1 inch
                    loc=3)
Comment

PREVIOUS NEXT
Code Example
Python :: link prettify in beautifulsoup 
Python :: Python String count() Implementation of the count() method using optional parameters 
Python :: PHP echo multi lines Using Heredoc variable 
Python :: accessing multiple elements from the list 
Python :: Grading program using if else 
Python :: Python 2 vs Python 3 Print Statement 
Python :: enumerate zip together 
Python :: df .isna percentage 
Python :: Add 1 to loops 
Python :: python comment faire une boucle 
Python :: python to uml 
Python :: how to add item to a list in pithon 
Python :: python jupyter show cell execution progress bar 
Python :: fetch metric data from aws boto3 
Python :: Python NumPy squeeze function Example with axis 
Python :: Python NumPy ravel function example Showing ordering manipulation 
Python :: manipulate sns legend 
Python :: Python NumPy asfortranarray Function Syntax 
Python :: Python NumPy row_stack Function Example with 2d array 
Python :: Python NumPy hsplit Function Syntax 
Python :: pass dictionary to random forest regressor 
Python :: NumPy rot90 Example Rotating Twice 
Python :: visualize 3 columns of pandas 
Python :: tikzplotlib set figure 
Python :: how to take input as an integer in python 
Python :: Creating a Nested Dictionary 
Python :: torch view vs unsqueeze 
Python :: python simplenamespace to json 
Python :: pyqt serial plotter 
Python :: HTML not being displayed properly in Flask, Python 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =