Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create different size matplotlib

import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec


def annotate_axes(fig):
    for i, ax in enumerate(fig.axes):
        ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
        ax.tick_params(labelbottom=False, labelleft=False)


fig = plt.figure()
fig.suptitle("Controlling subplot sizes with width_ratios and height_ratios")

gs = GridSpec(2, 2, width_ratios=[1, 2], height_ratios=[4, 1])
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1])
ax3 = fig.add_subplot(gs[2])
ax4 = fig.add_subplot(gs[3])

annotate_axes(fig)


fig = plt.figure()
fig.suptitle("Controlling spacing around and between subplots")

gs1 = GridSpec(3, 3, left=0.05, right=0.48, wspace=0.05)
ax1 = fig.add_subplot(gs1[:-1, :])
ax2 = fig.add_subplot(gs1[-1, :-1])
ax3 = fig.add_subplot(gs1[-1, -1])

gs2 = GridSpec(3, 3, left=0.55, right=0.98, hspace=0.05)
ax4 = fig.add_subplot(gs2[:, :-1])
ax5 = fig.add_subplot(gs2[:-1, -1])
ax6 = fig.add_subplot(gs2[-1, -1])

annotate_axes(fig)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: how to fetch limited rows in pandas dataframe using sqlalchemy 
Python :: pyqt log widget thread safe 
Python :: NumPy rot90 Example Rotating Once 
Python :: what are while loops in python 
Python :: calculate mse loss python 
Python :: how to split a string every 2 characters python 
Python :: visualize 3 columns of pandas 
Python :: NumPy left_shift Code When inputs and bit shift are numbers 
Python :: lambda function in python to shut ec2 at the time zone 
Python :: Break up long line of code to span over several lines 
Python :: python override inherited method data model constructor 
Python :: if not isinstance multiple values 
Python :: config.ini list not string 
Python :: Double all numbers using a map() and Lamda Function 
Python :: knn compute_distances_one_loop 
Python :: finding-the-largest-three-digits-number-within-a-number 
Python :: map reduce and filter functions in python 
Python :: groupby and add aggregated column 
Python :: how to end if else statement in python 
Python :: How to send an image that was sent with a post request to a model for prediction 
Python :: Creating 2-dimesional array 
Python :: EDA describe missing and zero values 
Python :: python entry element 
Python :: plt datas use left and right yaxes 
Python :: check string on substring godot 
Python :: salamelecus 
Python :: nth term of gp in python when 2,3 terms given 
Python :: custom 3d image generator for segmentation 
Python :: highly correlated features python 
Python :: how to perform a two-way anova with python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =