Axes with a fixed physical size

您所在的位置:网站首页 jkqt Axes with a fixed physical size

Axes with a fixed physical size

2023-10-19 09:56| 来源: 网络整理| 查看: 265

Note

Go to the end to download the full example code

Axes with a fixed physical size#

Note that this can be accomplished with the main library for Axes on Figures that do not change size: Adding single Axes at a time

import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import Divider, Size fig = plt.figure(figsize=(6, 6)) # The first items are for padding and the second items are for the axes. # sizes are in inch. h = [Size.Fixed(1.0), Size.Fixed(4.5)] v = [Size.Fixed(0.7), Size.Fixed(5.)] divider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False) # The width and height of the rectangle are ignored. ax = fig.add_axes(divider.get_position(), axes_locator=divider.new_locator(nx=1, ny=1)) ax.plot([1, 2, 3]) fig = plt.figure(figsize=(6, 6)) # The first & third items are for padding and the second items are for the # axes. Sizes are in inches. h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)] v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)] divider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False) # The width and height of the rectangle are ignored. ax = fig.add_axes(divider.get_position(), axes_locator=divider.new_locator(nx=1, ny=1)) ax.plot([1, 2, 3]) plt.show()

Download Python source code: demo_fixed_size_axes.py

Download Jupyter notebook: demo_fixed_size_axes.ipynb

Gallery generated by Sphinx-Gallery



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3